@xchainjs/xchain-thorchain-query 2.0.7 → 2.0.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 +82 -82
- package/lib/index.js +82 -82
- package/package.json +5 -5
package/lib/index.esm.js
CHANGED
|
@@ -41,55 +41,55 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
41
41
|
// Default attributes for each chain
|
|
42
42
|
const DefaultChainAttributes = {
|
|
43
43
|
BCH: {
|
|
44
|
-
blockReward: 6.25,
|
|
44
|
+
blockReward: 6.25, // Block reward for Bitcoin Cash
|
|
45
45
|
avgBlockTimeInSecs: 600, // Average block time for Bitcoin Cash in seconds
|
|
46
46
|
},
|
|
47
47
|
BTC: {
|
|
48
|
-
blockReward: 6.25,
|
|
48
|
+
blockReward: 6.25, // Block reward for Bitcoin
|
|
49
49
|
avgBlockTimeInSecs: 600, // Average block time for Bitcoin in seconds
|
|
50
50
|
},
|
|
51
51
|
ETH: {
|
|
52
|
-
blockReward: 2,
|
|
52
|
+
blockReward: 2, // Block reward for Ethereum
|
|
53
53
|
avgBlockTimeInSecs: 13, // Average block time for Ethereum in seconds
|
|
54
54
|
},
|
|
55
55
|
AVAX: {
|
|
56
|
-
blockReward: 2,
|
|
56
|
+
blockReward: 2, // Block reward for Avalanche
|
|
57
57
|
avgBlockTimeInSecs: 3, // Average block time for Avalanche in seconds
|
|
58
58
|
},
|
|
59
59
|
LTC: {
|
|
60
|
-
blockReward: 12.5,
|
|
60
|
+
blockReward: 12.5, // Block reward for Litecoin
|
|
61
61
|
avgBlockTimeInSecs: 150, // Average block time for Litecoin in seconds
|
|
62
62
|
},
|
|
63
63
|
DOGE: {
|
|
64
|
-
blockReward: 10000,
|
|
64
|
+
blockReward: 10000, // Block reward for Dogecoin
|
|
65
65
|
avgBlockTimeInSecs: 60, // Average block time for Dogecoin in seconds
|
|
66
66
|
},
|
|
67
67
|
GAIA: {
|
|
68
|
-
blockReward: 0,
|
|
68
|
+
blockReward: 0, // No block reward for Gaia
|
|
69
69
|
avgBlockTimeInSecs: 6, // Average block time for Gaia in seconds
|
|
70
70
|
},
|
|
71
71
|
THOR: {
|
|
72
|
-
blockReward: 0,
|
|
72
|
+
blockReward: 0, // No block reward for THORChain
|
|
73
73
|
avgBlockTimeInSecs: 6, // Average block time for THORChain in seconds
|
|
74
74
|
},
|
|
75
75
|
BSC: {
|
|
76
|
-
blockReward: 0,
|
|
76
|
+
blockReward: 0, // No block reward for Binance Smart Chain
|
|
77
77
|
avgBlockTimeInSecs: 3, // Average block time for Binance Smart Chain in seconds
|
|
78
78
|
},
|
|
79
79
|
MAYA: {
|
|
80
|
-
blockReward: 0,
|
|
80
|
+
blockReward: 0, // No block reward for MAYAChain
|
|
81
81
|
avgBlockTimeInSecs: 6, // Average block time for MAYAChain in seconds
|
|
82
82
|
},
|
|
83
83
|
BASE: {
|
|
84
|
-
blockReward: 0,
|
|
84
|
+
blockReward: 0, // No block reward for base
|
|
85
85
|
avgBlockTimeInSecs: 2, // Average block time for Base in seconds
|
|
86
86
|
},
|
|
87
87
|
XRP: {
|
|
88
|
-
blockReward: 0,
|
|
88
|
+
blockReward: 0, // No block reward for xrp
|
|
89
89
|
avgBlockTimeInSecs: 4, // Average block time for xrp in seconds
|
|
90
90
|
},
|
|
91
91
|
SOL: {
|
|
92
|
-
blockReward: 0,
|
|
92
|
+
blockReward: 0, // No block reward for sol
|
|
93
93
|
avgBlockTimeInSecs: 0.4, // Average block time for sol in seconds
|
|
94
94
|
},
|
|
95
95
|
};
|
|
@@ -1256,8 +1256,8 @@ class ThorchainQuery {
|
|
|
1256
1256
|
* @param quoteSwapParams - Input parameters for the swap quote.
|
|
1257
1257
|
* @returns Transaction details including memo, address, fees, etc.
|
|
1258
1258
|
*/
|
|
1259
|
-
quoteSwap(
|
|
1260
|
-
return __awaiter(this,
|
|
1259
|
+
quoteSwap(_a) {
|
|
1260
|
+
return __awaiter(this, arguments, void 0, function* ({ fromAsset, destinationAsset, amount, destinationAddress, streamingInterval, streamingQuantity, liquidityToleranceBps, toleranceBps, affiliateBps, affiliateAddress, height, }) {
|
|
1261
1261
|
// Validates swap and pushes error if there is one
|
|
1262
1262
|
const errors = [];
|
|
1263
1263
|
const error = yield this.validateAmount(amount);
|
|
@@ -1423,7 +1423,7 @@ class ThorchainQuery {
|
|
|
1423
1423
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1424
1424
|
// Return the fees converted to the specified asset
|
|
1425
1425
|
return {
|
|
1426
|
-
asset: fees.asset,
|
|
1426
|
+
asset: fees.asset, // Shouldn't be asset?
|
|
1427
1427
|
// swapFee: await this.convert(fees.swapFee, asset),
|
|
1428
1428
|
outboundFee: yield this.convert(fees.outboundFee, asset),
|
|
1429
1429
|
affiliateFee: yield this.convert(fees.affiliateFee, asset),
|
|
@@ -1672,34 +1672,34 @@ class ThorchainQuery {
|
|
|
1672
1672
|
const assetOutbound = calcOutboundFee(params.asset, inboundDetails);
|
|
1673
1673
|
// Create an EstimateWithdrawLP object
|
|
1674
1674
|
const estimateLP = {
|
|
1675
|
-
assetAddress: memberDetail.position.asset_address,
|
|
1676
|
-
runeAddress: memberDetail.position.rune_address,
|
|
1677
|
-
slipPercent: slip.times(100),
|
|
1675
|
+
assetAddress: memberDetail.position.asset_address, // Address for the asset
|
|
1676
|
+
runeAddress: memberDetail.position.rune_address, // Address for the rune
|
|
1677
|
+
slipPercent: slip.times(100), // Slip percentage
|
|
1678
1678
|
inbound: {
|
|
1679
1679
|
minToSend: {
|
|
1680
1680
|
// Minimum amount to send
|
|
1681
|
-
rune: dustValues.rune,
|
|
1682
|
-
asset: dustValues.asset,
|
|
1681
|
+
rune: dustValues.rune, // Rune amount
|
|
1682
|
+
asset: dustValues.asset, // Asset amount
|
|
1683
1683
|
total: (yield this.convert(dustValues.asset, AssetRuneNative)).plus(dustValues.rune), // Total amount
|
|
1684
1684
|
},
|
|
1685
1685
|
fees: {
|
|
1686
1686
|
// Inbound fees
|
|
1687
|
-
rune: runeInbound,
|
|
1688
|
-
asset: assetInbound,
|
|
1687
|
+
rune: runeInbound, // Rune fees
|
|
1688
|
+
asset: assetInbound, // Asset fees
|
|
1689
1689
|
total: (yield this.convert(assetInbound, AssetRuneNative)).plus(runeInbound), // Total fees
|
|
1690
1690
|
},
|
|
1691
1691
|
},
|
|
1692
1692
|
outboundFee: {
|
|
1693
1693
|
// Outbound fees
|
|
1694
|
-
asset: assetOutbound,
|
|
1695
|
-
rune: runeOutbound,
|
|
1694
|
+
asset: assetOutbound, // Asset fees
|
|
1695
|
+
rune: runeOutbound, // Rune fees
|
|
1696
1696
|
total: (yield this.convert(assetOutbound, AssetRuneNative)).plus(runeOutbound), // Total fees
|
|
1697
1697
|
},
|
|
1698
|
-
assetAmount: poolShare.assetShare,
|
|
1699
|
-
runeAmount: poolShare.runeShare,
|
|
1700
|
-
lpGrowth: memberDetail.lpGrowth,
|
|
1701
|
-
estimatedWaitSeconds: waitTimeSeconds,
|
|
1702
|
-
impermanentLossProtection: memberDetail.impermanentLossProtection,
|
|
1698
|
+
assetAmount: poolShare.assetShare, // Asset amount
|
|
1699
|
+
runeAmount: poolShare.runeShare, // Rune amount
|
|
1700
|
+
lpGrowth: memberDetail.lpGrowth, // LP growth
|
|
1701
|
+
estimatedWaitSeconds: waitTimeSeconds, // Estimated wait time in seconds
|
|
1702
|
+
impermanentLossProtection: memberDetail.impermanentLossProtection, // Impermanent loss protection
|
|
1703
1703
|
assetPool: assetPool.thornodeDetails.asset, // Asset pool
|
|
1704
1704
|
};
|
|
1705
1705
|
return estimateLP; // Return the EstimateWithdrawLP object
|
|
@@ -1836,7 +1836,7 @@ class ThorchainQuery {
|
|
|
1836
1836
|
// Affiliate fee
|
|
1837
1837
|
new CryptoAmount(baseAmount(depositQuote.fees.affiliate), addAmount.asset), // Convert to base amount
|
|
1838
1838
|
assetDecimals),
|
|
1839
|
-
asset: feeAsset,
|
|
1839
|
+
asset: feeAsset, // Asset fee
|
|
1840
1840
|
outbound: getCryptoAmountWithNotation(
|
|
1841
1841
|
// Outbound fee
|
|
1842
1842
|
new CryptoAmount(baseAmount(depositQuote.fees.outbound), feeAsset), // Convert to base amount
|
|
@@ -1859,15 +1859,15 @@ class ThorchainQuery {
|
|
|
1859
1859
|
// Estimated deposit value
|
|
1860
1860
|
new CryptoAmount(baseAmount(depositQuote.expected_amount_deposit), addAmount.asset), // Convert to base amount
|
|
1861
1861
|
assetDecimals),
|
|
1862
|
-
fee: saverFees,
|
|
1863
|
-
expiry: new Date(depositQuote.expiry),
|
|
1864
|
-
toAddress: depositQuote.inbound_address,
|
|
1865
|
-
memo: depositQuote.memo,
|
|
1866
|
-
estimatedWaitTime: depositQuote.inbound_confirmation_seconds || 0,
|
|
1867
|
-
canAddSaver: errors.length === 0,
|
|
1868
|
-
slipBasisPoints: depositQuote.fees.slippage_bps,
|
|
1869
|
-
saverCapFilledPercent,
|
|
1870
|
-
recommendedMinAmountIn: depositQuote.recommended_min_amount_in,
|
|
1862
|
+
fee: saverFees, // Fees
|
|
1863
|
+
expiry: new Date(depositQuote.expiry), // Expiry date
|
|
1864
|
+
toAddress: depositQuote.inbound_address, // Recipient address
|
|
1865
|
+
memo: depositQuote.memo, // Memo
|
|
1866
|
+
estimatedWaitTime: depositQuote.inbound_confirmation_seconds || 0, // Estimated wait time
|
|
1867
|
+
canAddSaver: errors.length === 0, // Can add saver flag
|
|
1868
|
+
slipBasisPoints: depositQuote.fees.slippage_bps, // Slip basis points
|
|
1869
|
+
saverCapFilledPercent, // Saver filled capacity
|
|
1870
|
+
recommendedMinAmountIn: depositQuote.recommended_min_amount_in, // Recommended minimum amount in
|
|
1871
1871
|
errors, // Errors
|
|
1872
1872
|
};
|
|
1873
1873
|
return estimateAddSaver; // Return the EstimateAddSaver object
|
|
@@ -1894,27 +1894,27 @@ class ThorchainQuery {
|
|
|
1894
1894
|
errors.push(checkPositon.errors[i]);
|
|
1895
1895
|
}
|
|
1896
1896
|
return {
|
|
1897
|
-
dustAmount: new AssetCryptoAmount(baseAmount(0), getChainAsset(withdrawParams.asset.chain)),
|
|
1898
|
-
dustThreshold: new AssetCryptoAmount(baseAmount(0), getChainAsset(withdrawParams.asset.chain)),
|
|
1897
|
+
dustAmount: new AssetCryptoAmount(baseAmount(0), getChainAsset(withdrawParams.asset.chain)), // Dust amount
|
|
1898
|
+
dustThreshold: new AssetCryptoAmount(baseAmount(0), getChainAsset(withdrawParams.asset.chain)), // Dust threshold
|
|
1899
1899
|
expectedAssetAmount: new CryptoAmount(// Expected asset amount
|
|
1900
1900
|
assetToBase(assetAmount(checkPositon.redeemableValue.assetAmount.amount())), // Convert to base amount
|
|
1901
1901
|
withdrawParams.asset),
|
|
1902
1902
|
fee: {
|
|
1903
|
-
affiliate: new CryptoAmount(assetToBase(assetAmount(0)), withdrawParams.asset),
|
|
1904
|
-
asset: withdrawParams.asset,
|
|
1905
|
-
liquidity: new CryptoAmount(baseAmount(0), withdrawParams.asset),
|
|
1903
|
+
affiliate: new CryptoAmount(assetToBase(assetAmount(0)), withdrawParams.asset), // Affiliate fee
|
|
1904
|
+
asset: withdrawParams.asset, // Asset
|
|
1905
|
+
liquidity: new CryptoAmount(baseAmount(0), withdrawParams.asset), // Liquidity fee
|
|
1906
1906
|
outbound: new CryptoAmount(// Outbound fee
|
|
1907
1907
|
assetToBase(assetAmount(calcOutboundFee(withdrawParams.asset, inboundDetails[withdrawParams.asset.chain]).assetAmount.amount())), withdrawParams.asset),
|
|
1908
1908
|
totalBps: 0, // Total basis points
|
|
1909
1909
|
},
|
|
1910
|
-
expiry: new Date(0),
|
|
1911
|
-
toAddress: '',
|
|
1912
|
-
memo: '',
|
|
1913
|
-
inboundDelayBlocks: 0,
|
|
1914
|
-
inboundDelaySeconds: 0,
|
|
1915
|
-
outBoundDelayBlocks: 0,
|
|
1916
|
-
outBoundDelaySeconds: 0,
|
|
1917
|
-
slipBasisPoints: -1,
|
|
1910
|
+
expiry: new Date(0), // Expiry date
|
|
1911
|
+
toAddress: '', // Recipient address
|
|
1912
|
+
memo: '', // Memo
|
|
1913
|
+
inboundDelayBlocks: 0, // Number of blocks for inbound delay
|
|
1914
|
+
inboundDelaySeconds: 0, // Number of seconds for inbound delay
|
|
1915
|
+
outBoundDelayBlocks: 0, // Number of blocks for outbound delay
|
|
1916
|
+
outBoundDelaySeconds: 0, // Number of seconds for outbound delay
|
|
1917
|
+
slipBasisPoints: -1, // Slip basis points (negative value indicates no slip)
|
|
1918
1918
|
errors, // Errors array
|
|
1919
1919
|
};
|
|
1920
1920
|
}
|
|
@@ -2042,13 +2042,13 @@ class ThorchainQuery {
|
|
|
2042
2042
|
const saverGrowth = redeemableAssetAmount.minus(depositAmount).div(depositAmount).times(100);
|
|
2043
2043
|
// Create and populate a SaversPosition object with the calculated values
|
|
2044
2044
|
const saversPos = {
|
|
2045
|
-
depositValue: depositAmount,
|
|
2046
|
-
redeemableValue: redeemableAssetAmount,
|
|
2047
|
-
lastAddHeight: Number(savers === null || savers === void 0 ? void 0 : savers.last_add_height),
|
|
2048
|
-
percentageGrowth: saverGrowth.assetAmount.amount().toNumber(),
|
|
2049
|
-
ageInYears: saversAge,
|
|
2050
|
-
ageInDays: saversAge * 365,
|
|
2051
|
-
asset: params.asset,
|
|
2045
|
+
depositValue: depositAmount, // Current deposit value of the saver
|
|
2046
|
+
redeemableValue: redeemableAssetAmount, // Redeemable value of the saver's position
|
|
2047
|
+
lastAddHeight: Number(savers === null || savers === void 0 ? void 0 : savers.last_add_height), // Height at which the last addition was made to the pool
|
|
2048
|
+
percentageGrowth: saverGrowth.assetAmount.amount().toNumber(), // Percentage growth of the saver's position
|
|
2049
|
+
ageInYears: saversAge, // Age of the saver's position in years
|
|
2050
|
+
ageInDays: saversAge * 365, // Age of the saver's position in days
|
|
2051
|
+
asset: params.asset, // Asset of the saver's position
|
|
2052
2052
|
errors, // Array of any errors encountered during the calculation
|
|
2053
2053
|
};
|
|
2054
2054
|
// Return the SaversPosition object representing the saver's position
|
|
@@ -2098,8 +2098,8 @@ class ThorchainQuery {
|
|
|
2098
2098
|
* @param loanOpenParams - params needed for the end Point
|
|
2099
2099
|
* @returns
|
|
2100
2100
|
*/
|
|
2101
|
-
getLoanQuoteOpen(
|
|
2102
|
-
return __awaiter(this,
|
|
2101
|
+
getLoanQuoteOpen(_a) {
|
|
2102
|
+
return __awaiter(this, arguments, void 0, function* ({ asset, amount, targetAsset, destination, minOut, affiliateBps, affiliate, height, }) {
|
|
2103
2103
|
const errors = [];
|
|
2104
2104
|
const loanOpenResp = yield this.thorchainCache.thornode.getLoanQuoteOpen(`${asset.chain}.${asset.symbol}`, amount.baseAmount.amount().toNumber(), `${targetAsset.chain}.${targetAsset.symbol}`, destination, minOut, affiliateBps, affiliate, height);
|
|
2105
2105
|
const response = JSON.parse(JSON.stringify(loanOpenResp));
|
|
@@ -2170,8 +2170,8 @@ class ThorchainQuery {
|
|
|
2170
2170
|
* @param loanOpenParams - Parameters needed for the endpoint.
|
|
2171
2171
|
* @returns A Promise resolving to a LoanOpenQuote.
|
|
2172
2172
|
*/
|
|
2173
|
-
getLoanQuoteClose(
|
|
2174
|
-
return __awaiter(this,
|
|
2173
|
+
getLoanQuoteClose(_a) {
|
|
2174
|
+
return __awaiter(this, arguments, void 0, function* ({ asset, amount, loanAsset, loanOwner, minOut, height, }) {
|
|
2175
2175
|
const errors = [];
|
|
2176
2176
|
// Retrieve loan open response from ThorNode API
|
|
2177
2177
|
const loanCloseResp = yield this.thorchainCache.thornode.getLoanQuoteClose(`${asset.chain}.${asset.symbol}`, amount.baseAmount.amount().toNumber(), `${loanAsset.chain}.${loanAsset.symbol}`, loanOwner, minOut, height);
|
|
@@ -2374,8 +2374,8 @@ class ThorchainQuery {
|
|
|
2374
2374
|
* @param {Address[]} params.addresses - List of addresses
|
|
2375
2375
|
* @returns {SwapsHistory} Swap history
|
|
2376
2376
|
*/
|
|
2377
|
-
getSwapHistory(
|
|
2378
|
-
return __awaiter(this,
|
|
2377
|
+
getSwapHistory(_a) {
|
|
2378
|
+
return __awaiter(this, arguments, void 0, function* ({ addresses }) {
|
|
2379
2379
|
const actionsResume = yield this.thorchainCache.midgardQuery.midgardCache.midgard.getActions({
|
|
2380
2380
|
address: addresses.join(','),
|
|
2381
2381
|
type: 'swap',
|
|
@@ -2430,8 +2430,8 @@ class ThorchainQuery {
|
|
|
2430
2430
|
* @param {TradeAssetUnitsParams} params Get trade asset unit params
|
|
2431
2431
|
* @returns {TradeAssetUnits} Returns the total units and depth of a trade asset
|
|
2432
2432
|
*/
|
|
2433
|
-
getTradeAssetUnits(
|
|
2434
|
-
return __awaiter(this,
|
|
2433
|
+
getTradeAssetUnits(_a) {
|
|
2434
|
+
return __awaiter(this, arguments, void 0, function* ({ asset, height }) {
|
|
2435
2435
|
const { units, depth } = yield this.thorchainCache.thornode.getTradeAssetUnits(assetToString(asset), height);
|
|
2436
2436
|
const decimals = yield this.thorchainCache.midgardQuery.getDecimalForAsset(asset);
|
|
2437
2437
|
return {
|
|
@@ -2449,7 +2449,7 @@ class ThorchainQuery {
|
|
|
2449
2449
|
getTradeAssetsUnits(params) {
|
|
2450
2450
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2451
2451
|
const tradeAssetsUnits = yield this.thorchainCache.thornode.getTradeAssetsUnits(params === null || params === void 0 ? void 0 : params.height);
|
|
2452
|
-
const parseData = (
|
|
2452
|
+
const parseData = (_a) => __awaiter(this, [_a], void 0, function* ({ asset, units, depth }) {
|
|
2453
2453
|
const tradeAsset = assetFromStringEx(asset);
|
|
2454
2454
|
const decimals = yield this.thorchainCache.midgardQuery.getDecimalForAsset(tradeAsset);
|
|
2455
2455
|
return {
|
|
@@ -2466,8 +2466,8 @@ class ThorchainQuery {
|
|
|
2466
2466
|
* @param {TradeAssetsUnitsParams} params Get trade asset unit params
|
|
2467
2467
|
* @returns {TradeAssetUnits[]} Returns the total units and depth for each trade asset
|
|
2468
2468
|
*/
|
|
2469
|
-
getAddressTradeAccounts(
|
|
2470
|
-
return __awaiter(this,
|
|
2469
|
+
getAddressTradeAccounts(_a) {
|
|
2470
|
+
return __awaiter(this, arguments, void 0, function* ({ address, height, }) {
|
|
2471
2471
|
const account = yield this.thorchainCache.thornode.getTradeAssetAccount(address, height);
|
|
2472
2472
|
const parseData = (tradeAssetInfo) => __awaiter(this, void 0, void 0, function* () {
|
|
2473
2473
|
const asset = assetFromStringEx(tradeAssetInfo.asset);
|
|
@@ -2488,8 +2488,8 @@ class ThorchainQuery {
|
|
|
2488
2488
|
* @param {number} height Optional - Block height
|
|
2489
2489
|
* @returns Returns all trade accounts for an asset
|
|
2490
2490
|
*/
|
|
2491
|
-
getTradeAssetAccounts(
|
|
2492
|
-
return __awaiter(this,
|
|
2491
|
+
getTradeAssetAccounts(_a) {
|
|
2492
|
+
return __awaiter(this, arguments, void 0, function* ({ asset, height }) {
|
|
2493
2493
|
const accounts = yield this.thorchainCache.thornode.getTradeAssetAccounts(assetToString(asset), height);
|
|
2494
2494
|
const decimals = yield this.thorchainCache.midgardQuery.getDecimalForAsset(asset);
|
|
2495
2495
|
return accounts.map((account) => {
|
|
@@ -2541,8 +2541,8 @@ class ThorchainQuery {
|
|
|
2541
2541
|
* @param {RunePoolProviderParams} params Get Rune pool provider position params
|
|
2542
2542
|
* @returns {RunePoolProvider} Rune pool provider position
|
|
2543
2543
|
*/
|
|
2544
|
-
getRunePoolProvider(
|
|
2545
|
-
return __awaiter(this,
|
|
2544
|
+
getRunePoolProvider(_a) {
|
|
2545
|
+
return __awaiter(this, arguments, void 0, function* ({ address, height }) {
|
|
2546
2546
|
const position = yield this.thorchainCache.thornode.getRunePoolProvider(address, height);
|
|
2547
2547
|
return {
|
|
2548
2548
|
address: position.rune_address,
|
|
@@ -2763,8 +2763,8 @@ class TransactionStage {
|
|
|
2763
2763
|
* @param progress - Transaction progress object.
|
|
2764
2764
|
*/
|
|
2765
2765
|
checkSwapProgress(txData, progress) {
|
|
2766
|
-
var _a, _b, _c, _d;
|
|
2767
2766
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2767
|
+
var _a, _b, _c, _d;
|
|
2768
2768
|
if (progress.inboundObserved) {
|
|
2769
2769
|
// Extract memo fields
|
|
2770
2770
|
const memo = (_a = txData.tx.tx.memo) !== null && _a !== void 0 ? _a : '';
|
|
@@ -2792,7 +2792,7 @@ class TransactionStage {
|
|
|
2792
2792
|
status: swapStatus,
|
|
2793
2793
|
expectedOutBlock,
|
|
2794
2794
|
expectedOutDate,
|
|
2795
|
-
expectedAmountOut: minimumAmountOut,
|
|
2795
|
+
expectedAmountOut: minimumAmountOut, // TODO call estimateSwap()
|
|
2796
2796
|
confirmations,
|
|
2797
2797
|
minimumAmountOut,
|
|
2798
2798
|
affliateFee,
|
|
@@ -2837,8 +2837,8 @@ class TransactionStage {
|
|
|
2837
2837
|
* @returns Promise<TXProgress> - Transaction progress object.
|
|
2838
2838
|
*/
|
|
2839
2839
|
determineObserved(txData) {
|
|
2840
|
-
var _a, _b, _c, _d;
|
|
2841
2840
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2841
|
+
var _a, _b, _c, _d;
|
|
2842
2842
|
const progress = {
|
|
2843
2843
|
txType: TxType.Unknown,
|
|
2844
2844
|
};
|
|
@@ -2874,7 +2874,7 @@ class TransactionStage {
|
|
|
2874
2874
|
: yield this.blockToDate(assetIn.chain, txData);
|
|
2875
2875
|
progress.inboundObserved = {
|
|
2876
2876
|
status,
|
|
2877
|
-
date: dateObserved,
|
|
2877
|
+
date: dateObserved, // date observed?
|
|
2878
2878
|
block,
|
|
2879
2879
|
expectedConfirmationBlock: finalizeBlock,
|
|
2880
2880
|
expectedConfirmationDate,
|
|
@@ -2892,8 +2892,8 @@ class TransactionStage {
|
|
|
2892
2892
|
* @param progress - Transaction progress object.
|
|
2893
2893
|
*/
|
|
2894
2894
|
checkAddLpProgress(txData, progress) {
|
|
2895
|
-
var _a;
|
|
2896
2895
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2896
|
+
var _a;
|
|
2897
2897
|
if (progress.inboundObserved) {
|
|
2898
2898
|
// Extract memo fields
|
|
2899
2899
|
const memo = (_a = txData.tx.tx.memo) !== null && _a !== void 0 ? _a : '';
|
|
@@ -2924,8 +2924,8 @@ class TransactionStage {
|
|
|
2924
2924
|
* @param progress - Transaction progress object.
|
|
2925
2925
|
*/
|
|
2926
2926
|
checkWithdrawLpProgress(txData, progress) {
|
|
2927
|
-
var _a, _b;
|
|
2928
2927
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2928
|
+
var _a, _b;
|
|
2929
2929
|
if (progress.inboundObserved) {
|
|
2930
2930
|
// Extract memo fields
|
|
2931
2931
|
const memo = (_a = txData.tx.tx.memo) !== null && _a !== void 0 ? _a : '';
|
|
@@ -2994,8 +2994,8 @@ class TransactionStage {
|
|
|
2994
2994
|
* @param progress - Transaction progress object.
|
|
2995
2995
|
*/
|
|
2996
2996
|
checkWithdrawSaverProgress(txData, progress) {
|
|
2997
|
-
var _a;
|
|
2998
2997
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2998
|
+
var _a;
|
|
2999
2999
|
if (progress.inboundObserved) {
|
|
3000
3000
|
// Extract memo fields
|
|
3001
3001
|
const memo = (_a = txData.tx.tx.memo) !== null && _a !== void 0 ? _a : '';
|
package/lib/index.js
CHANGED
|
@@ -49,55 +49,55 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
49
49
|
// Default attributes for each chain
|
|
50
50
|
const DefaultChainAttributes = {
|
|
51
51
|
BCH: {
|
|
52
|
-
blockReward: 6.25,
|
|
52
|
+
blockReward: 6.25, // Block reward for Bitcoin Cash
|
|
53
53
|
avgBlockTimeInSecs: 600, // Average block time for Bitcoin Cash in seconds
|
|
54
54
|
},
|
|
55
55
|
BTC: {
|
|
56
|
-
blockReward: 6.25,
|
|
56
|
+
blockReward: 6.25, // Block reward for Bitcoin
|
|
57
57
|
avgBlockTimeInSecs: 600, // Average block time for Bitcoin in seconds
|
|
58
58
|
},
|
|
59
59
|
ETH: {
|
|
60
|
-
blockReward: 2,
|
|
60
|
+
blockReward: 2, // Block reward for Ethereum
|
|
61
61
|
avgBlockTimeInSecs: 13, // Average block time for Ethereum in seconds
|
|
62
62
|
},
|
|
63
63
|
AVAX: {
|
|
64
|
-
blockReward: 2,
|
|
64
|
+
blockReward: 2, // Block reward for Avalanche
|
|
65
65
|
avgBlockTimeInSecs: 3, // Average block time for Avalanche in seconds
|
|
66
66
|
},
|
|
67
67
|
LTC: {
|
|
68
|
-
blockReward: 12.5,
|
|
68
|
+
blockReward: 12.5, // Block reward for Litecoin
|
|
69
69
|
avgBlockTimeInSecs: 150, // Average block time for Litecoin in seconds
|
|
70
70
|
},
|
|
71
71
|
DOGE: {
|
|
72
|
-
blockReward: 10000,
|
|
72
|
+
blockReward: 10000, // Block reward for Dogecoin
|
|
73
73
|
avgBlockTimeInSecs: 60, // Average block time for Dogecoin in seconds
|
|
74
74
|
},
|
|
75
75
|
GAIA: {
|
|
76
|
-
blockReward: 0,
|
|
76
|
+
blockReward: 0, // No block reward for Gaia
|
|
77
77
|
avgBlockTimeInSecs: 6, // Average block time for Gaia in seconds
|
|
78
78
|
},
|
|
79
79
|
THOR: {
|
|
80
|
-
blockReward: 0,
|
|
80
|
+
blockReward: 0, // No block reward for THORChain
|
|
81
81
|
avgBlockTimeInSecs: 6, // Average block time for THORChain in seconds
|
|
82
82
|
},
|
|
83
83
|
BSC: {
|
|
84
|
-
blockReward: 0,
|
|
84
|
+
blockReward: 0, // No block reward for Binance Smart Chain
|
|
85
85
|
avgBlockTimeInSecs: 3, // Average block time for Binance Smart Chain in seconds
|
|
86
86
|
},
|
|
87
87
|
MAYA: {
|
|
88
|
-
blockReward: 0,
|
|
88
|
+
blockReward: 0, // No block reward for MAYAChain
|
|
89
89
|
avgBlockTimeInSecs: 6, // Average block time for MAYAChain in seconds
|
|
90
90
|
},
|
|
91
91
|
BASE: {
|
|
92
|
-
blockReward: 0,
|
|
92
|
+
blockReward: 0, // No block reward for base
|
|
93
93
|
avgBlockTimeInSecs: 2, // Average block time for Base in seconds
|
|
94
94
|
},
|
|
95
95
|
XRP: {
|
|
96
|
-
blockReward: 0,
|
|
96
|
+
blockReward: 0, // No block reward for xrp
|
|
97
97
|
avgBlockTimeInSecs: 4, // Average block time for xrp in seconds
|
|
98
98
|
},
|
|
99
99
|
SOL: {
|
|
100
|
-
blockReward: 0,
|
|
100
|
+
blockReward: 0, // No block reward for sol
|
|
101
101
|
avgBlockTimeInSecs: 0.4, // Average block time for sol in seconds
|
|
102
102
|
},
|
|
103
103
|
};
|
|
@@ -1264,8 +1264,8 @@ class ThorchainQuery {
|
|
|
1264
1264
|
* @param quoteSwapParams - Input parameters for the swap quote.
|
|
1265
1265
|
* @returns Transaction details including memo, address, fees, etc.
|
|
1266
1266
|
*/
|
|
1267
|
-
quoteSwap(
|
|
1268
|
-
return __awaiter(this,
|
|
1267
|
+
quoteSwap(_a) {
|
|
1268
|
+
return __awaiter(this, arguments, void 0, function* ({ fromAsset, destinationAsset, amount, destinationAddress, streamingInterval, streamingQuantity, liquidityToleranceBps, toleranceBps, affiliateBps, affiliateAddress, height, }) {
|
|
1269
1269
|
// Validates swap and pushes error if there is one
|
|
1270
1270
|
const errors = [];
|
|
1271
1271
|
const error = yield this.validateAmount(amount);
|
|
@@ -1431,7 +1431,7 @@ class ThorchainQuery {
|
|
|
1431
1431
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1432
1432
|
// Return the fees converted to the specified asset
|
|
1433
1433
|
return {
|
|
1434
|
-
asset: fees.asset,
|
|
1434
|
+
asset: fees.asset, // Shouldn't be asset?
|
|
1435
1435
|
// swapFee: await this.convert(fees.swapFee, asset),
|
|
1436
1436
|
outboundFee: yield this.convert(fees.outboundFee, asset),
|
|
1437
1437
|
affiliateFee: yield this.convert(fees.affiliateFee, asset),
|
|
@@ -1680,34 +1680,34 @@ class ThorchainQuery {
|
|
|
1680
1680
|
const assetOutbound = calcOutboundFee(params.asset, inboundDetails);
|
|
1681
1681
|
// Create an EstimateWithdrawLP object
|
|
1682
1682
|
const estimateLP = {
|
|
1683
|
-
assetAddress: memberDetail.position.asset_address,
|
|
1684
|
-
runeAddress: memberDetail.position.rune_address,
|
|
1685
|
-
slipPercent: slip.times(100),
|
|
1683
|
+
assetAddress: memberDetail.position.asset_address, // Address for the asset
|
|
1684
|
+
runeAddress: memberDetail.position.rune_address, // Address for the rune
|
|
1685
|
+
slipPercent: slip.times(100), // Slip percentage
|
|
1686
1686
|
inbound: {
|
|
1687
1687
|
minToSend: {
|
|
1688
1688
|
// Minimum amount to send
|
|
1689
|
-
rune: dustValues.rune,
|
|
1690
|
-
asset: dustValues.asset,
|
|
1689
|
+
rune: dustValues.rune, // Rune amount
|
|
1690
|
+
asset: dustValues.asset, // Asset amount
|
|
1691
1691
|
total: (yield this.convert(dustValues.asset, AssetRuneNative)).plus(dustValues.rune), // Total amount
|
|
1692
1692
|
},
|
|
1693
1693
|
fees: {
|
|
1694
1694
|
// Inbound fees
|
|
1695
|
-
rune: runeInbound,
|
|
1696
|
-
asset: assetInbound,
|
|
1695
|
+
rune: runeInbound, // Rune fees
|
|
1696
|
+
asset: assetInbound, // Asset fees
|
|
1697
1697
|
total: (yield this.convert(assetInbound, AssetRuneNative)).plus(runeInbound), // Total fees
|
|
1698
1698
|
},
|
|
1699
1699
|
},
|
|
1700
1700
|
outboundFee: {
|
|
1701
1701
|
// Outbound fees
|
|
1702
|
-
asset: assetOutbound,
|
|
1703
|
-
rune: runeOutbound,
|
|
1702
|
+
asset: assetOutbound, // Asset fees
|
|
1703
|
+
rune: runeOutbound, // Rune fees
|
|
1704
1704
|
total: (yield this.convert(assetOutbound, AssetRuneNative)).plus(runeOutbound), // Total fees
|
|
1705
1705
|
},
|
|
1706
|
-
assetAmount: poolShare.assetShare,
|
|
1707
|
-
runeAmount: poolShare.runeShare,
|
|
1708
|
-
lpGrowth: memberDetail.lpGrowth,
|
|
1709
|
-
estimatedWaitSeconds: waitTimeSeconds,
|
|
1710
|
-
impermanentLossProtection: memberDetail.impermanentLossProtection,
|
|
1706
|
+
assetAmount: poolShare.assetShare, // Asset amount
|
|
1707
|
+
runeAmount: poolShare.runeShare, // Rune amount
|
|
1708
|
+
lpGrowth: memberDetail.lpGrowth, // LP growth
|
|
1709
|
+
estimatedWaitSeconds: waitTimeSeconds, // Estimated wait time in seconds
|
|
1710
|
+
impermanentLossProtection: memberDetail.impermanentLossProtection, // Impermanent loss protection
|
|
1711
1711
|
assetPool: assetPool.thornodeDetails.asset, // Asset pool
|
|
1712
1712
|
};
|
|
1713
1713
|
return estimateLP; // Return the EstimateWithdrawLP object
|
|
@@ -1844,7 +1844,7 @@ class ThorchainQuery {
|
|
|
1844
1844
|
// Affiliate fee
|
|
1845
1845
|
new xchainUtil.CryptoAmount(xchainUtil.baseAmount(depositQuote.fees.affiliate), addAmount.asset), // Convert to base amount
|
|
1846
1846
|
assetDecimals),
|
|
1847
|
-
asset: feeAsset,
|
|
1847
|
+
asset: feeAsset, // Asset fee
|
|
1848
1848
|
outbound: getCryptoAmountWithNotation(
|
|
1849
1849
|
// Outbound fee
|
|
1850
1850
|
new xchainUtil.CryptoAmount(xchainUtil.baseAmount(depositQuote.fees.outbound), feeAsset), // Convert to base amount
|
|
@@ -1867,15 +1867,15 @@ class ThorchainQuery {
|
|
|
1867
1867
|
// Estimated deposit value
|
|
1868
1868
|
new xchainUtil.CryptoAmount(xchainUtil.baseAmount(depositQuote.expected_amount_deposit), addAmount.asset), // Convert to base amount
|
|
1869
1869
|
assetDecimals),
|
|
1870
|
-
fee: saverFees,
|
|
1871
|
-
expiry: new Date(depositQuote.expiry),
|
|
1872
|
-
toAddress: depositQuote.inbound_address,
|
|
1873
|
-
memo: depositQuote.memo,
|
|
1874
|
-
estimatedWaitTime: depositQuote.inbound_confirmation_seconds || 0,
|
|
1875
|
-
canAddSaver: errors.length === 0,
|
|
1876
|
-
slipBasisPoints: depositQuote.fees.slippage_bps,
|
|
1877
|
-
saverCapFilledPercent,
|
|
1878
|
-
recommendedMinAmountIn: depositQuote.recommended_min_amount_in,
|
|
1870
|
+
fee: saverFees, // Fees
|
|
1871
|
+
expiry: new Date(depositQuote.expiry), // Expiry date
|
|
1872
|
+
toAddress: depositQuote.inbound_address, // Recipient address
|
|
1873
|
+
memo: depositQuote.memo, // Memo
|
|
1874
|
+
estimatedWaitTime: depositQuote.inbound_confirmation_seconds || 0, // Estimated wait time
|
|
1875
|
+
canAddSaver: errors.length === 0, // Can add saver flag
|
|
1876
|
+
slipBasisPoints: depositQuote.fees.slippage_bps, // Slip basis points
|
|
1877
|
+
saverCapFilledPercent, // Saver filled capacity
|
|
1878
|
+
recommendedMinAmountIn: depositQuote.recommended_min_amount_in, // Recommended minimum amount in
|
|
1879
1879
|
errors, // Errors
|
|
1880
1880
|
};
|
|
1881
1881
|
return estimateAddSaver; // Return the EstimateAddSaver object
|
|
@@ -1902,27 +1902,27 @@ class ThorchainQuery {
|
|
|
1902
1902
|
errors.push(checkPositon.errors[i]);
|
|
1903
1903
|
}
|
|
1904
1904
|
return {
|
|
1905
|
-
dustAmount: new xchainUtil.AssetCryptoAmount(xchainUtil.baseAmount(0), getChainAsset(withdrawParams.asset.chain)),
|
|
1906
|
-
dustThreshold: new xchainUtil.AssetCryptoAmount(xchainUtil.baseAmount(0), getChainAsset(withdrawParams.asset.chain)),
|
|
1905
|
+
dustAmount: new xchainUtil.AssetCryptoAmount(xchainUtil.baseAmount(0), getChainAsset(withdrawParams.asset.chain)), // Dust amount
|
|
1906
|
+
dustThreshold: new xchainUtil.AssetCryptoAmount(xchainUtil.baseAmount(0), getChainAsset(withdrawParams.asset.chain)), // Dust threshold
|
|
1907
1907
|
expectedAssetAmount: new xchainUtil.CryptoAmount(// Expected asset amount
|
|
1908
1908
|
xchainUtil.assetToBase(xchainUtil.assetAmount(checkPositon.redeemableValue.assetAmount.amount())), // Convert to base amount
|
|
1909
1909
|
withdrawParams.asset),
|
|
1910
1910
|
fee: {
|
|
1911
|
-
affiliate: new xchainUtil.CryptoAmount(xchainUtil.assetToBase(xchainUtil.assetAmount(0)), withdrawParams.asset),
|
|
1912
|
-
asset: withdrawParams.asset,
|
|
1913
|
-
liquidity: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(0), withdrawParams.asset),
|
|
1911
|
+
affiliate: new xchainUtil.CryptoAmount(xchainUtil.assetToBase(xchainUtil.assetAmount(0)), withdrawParams.asset), // Affiliate fee
|
|
1912
|
+
asset: withdrawParams.asset, // Asset
|
|
1913
|
+
liquidity: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(0), withdrawParams.asset), // Liquidity fee
|
|
1914
1914
|
outbound: new xchainUtil.CryptoAmount(// Outbound fee
|
|
1915
1915
|
xchainUtil.assetToBase(xchainUtil.assetAmount(calcOutboundFee(withdrawParams.asset, inboundDetails[withdrawParams.asset.chain]).assetAmount.amount())), withdrawParams.asset),
|
|
1916
1916
|
totalBps: 0, // Total basis points
|
|
1917
1917
|
},
|
|
1918
|
-
expiry: new Date(0),
|
|
1919
|
-
toAddress: '',
|
|
1920
|
-
memo: '',
|
|
1921
|
-
inboundDelayBlocks: 0,
|
|
1922
|
-
inboundDelaySeconds: 0,
|
|
1923
|
-
outBoundDelayBlocks: 0,
|
|
1924
|
-
outBoundDelaySeconds: 0,
|
|
1925
|
-
slipBasisPoints: -1,
|
|
1918
|
+
expiry: new Date(0), // Expiry date
|
|
1919
|
+
toAddress: '', // Recipient address
|
|
1920
|
+
memo: '', // Memo
|
|
1921
|
+
inboundDelayBlocks: 0, // Number of blocks for inbound delay
|
|
1922
|
+
inboundDelaySeconds: 0, // Number of seconds for inbound delay
|
|
1923
|
+
outBoundDelayBlocks: 0, // Number of blocks for outbound delay
|
|
1924
|
+
outBoundDelaySeconds: 0, // Number of seconds for outbound delay
|
|
1925
|
+
slipBasisPoints: -1, // Slip basis points (negative value indicates no slip)
|
|
1926
1926
|
errors, // Errors array
|
|
1927
1927
|
};
|
|
1928
1928
|
}
|
|
@@ -2050,13 +2050,13 @@ class ThorchainQuery {
|
|
|
2050
2050
|
const saverGrowth = redeemableAssetAmount.minus(depositAmount).div(depositAmount).times(100);
|
|
2051
2051
|
// Create and populate a SaversPosition object with the calculated values
|
|
2052
2052
|
const saversPos = {
|
|
2053
|
-
depositValue: depositAmount,
|
|
2054
|
-
redeemableValue: redeemableAssetAmount,
|
|
2055
|
-
lastAddHeight: Number(savers === null || savers === void 0 ? void 0 : savers.last_add_height),
|
|
2056
|
-
percentageGrowth: saverGrowth.assetAmount.amount().toNumber(),
|
|
2057
|
-
ageInYears: saversAge,
|
|
2058
|
-
ageInDays: saversAge * 365,
|
|
2059
|
-
asset: params.asset,
|
|
2053
|
+
depositValue: depositAmount, // Current deposit value of the saver
|
|
2054
|
+
redeemableValue: redeemableAssetAmount, // Redeemable value of the saver's position
|
|
2055
|
+
lastAddHeight: Number(savers === null || savers === void 0 ? void 0 : savers.last_add_height), // Height at which the last addition was made to the pool
|
|
2056
|
+
percentageGrowth: saverGrowth.assetAmount.amount().toNumber(), // Percentage growth of the saver's position
|
|
2057
|
+
ageInYears: saversAge, // Age of the saver's position in years
|
|
2058
|
+
ageInDays: saversAge * 365, // Age of the saver's position in days
|
|
2059
|
+
asset: params.asset, // Asset of the saver's position
|
|
2060
2060
|
errors, // Array of any errors encountered during the calculation
|
|
2061
2061
|
};
|
|
2062
2062
|
// Return the SaversPosition object representing the saver's position
|
|
@@ -2106,8 +2106,8 @@ class ThorchainQuery {
|
|
|
2106
2106
|
* @param loanOpenParams - params needed for the end Point
|
|
2107
2107
|
* @returns
|
|
2108
2108
|
*/
|
|
2109
|
-
getLoanQuoteOpen(
|
|
2110
|
-
return __awaiter(this,
|
|
2109
|
+
getLoanQuoteOpen(_a) {
|
|
2110
|
+
return __awaiter(this, arguments, void 0, function* ({ asset, amount, targetAsset, destination, minOut, affiliateBps, affiliate, height, }) {
|
|
2111
2111
|
const errors = [];
|
|
2112
2112
|
const loanOpenResp = yield this.thorchainCache.thornode.getLoanQuoteOpen(`${asset.chain}.${asset.symbol}`, amount.baseAmount.amount().toNumber(), `${targetAsset.chain}.${targetAsset.symbol}`, destination, minOut, affiliateBps, affiliate, height);
|
|
2113
2113
|
const response = JSON.parse(JSON.stringify(loanOpenResp));
|
|
@@ -2178,8 +2178,8 @@ class ThorchainQuery {
|
|
|
2178
2178
|
* @param loanOpenParams - Parameters needed for the endpoint.
|
|
2179
2179
|
* @returns A Promise resolving to a LoanOpenQuote.
|
|
2180
2180
|
*/
|
|
2181
|
-
getLoanQuoteClose(
|
|
2182
|
-
return __awaiter(this,
|
|
2181
|
+
getLoanQuoteClose(_a) {
|
|
2182
|
+
return __awaiter(this, arguments, void 0, function* ({ asset, amount, loanAsset, loanOwner, minOut, height, }) {
|
|
2183
2183
|
const errors = [];
|
|
2184
2184
|
// Retrieve loan open response from ThorNode API
|
|
2185
2185
|
const loanCloseResp = yield this.thorchainCache.thornode.getLoanQuoteClose(`${asset.chain}.${asset.symbol}`, amount.baseAmount.amount().toNumber(), `${loanAsset.chain}.${loanAsset.symbol}`, loanOwner, minOut, height);
|
|
@@ -2382,8 +2382,8 @@ class ThorchainQuery {
|
|
|
2382
2382
|
* @param {Address[]} params.addresses - List of addresses
|
|
2383
2383
|
* @returns {SwapsHistory} Swap history
|
|
2384
2384
|
*/
|
|
2385
|
-
getSwapHistory(
|
|
2386
|
-
return __awaiter(this,
|
|
2385
|
+
getSwapHistory(_a) {
|
|
2386
|
+
return __awaiter(this, arguments, void 0, function* ({ addresses }) {
|
|
2387
2387
|
const actionsResume = yield this.thorchainCache.midgardQuery.midgardCache.midgard.getActions({
|
|
2388
2388
|
address: addresses.join(','),
|
|
2389
2389
|
type: 'swap',
|
|
@@ -2438,8 +2438,8 @@ class ThorchainQuery {
|
|
|
2438
2438
|
* @param {TradeAssetUnitsParams} params Get trade asset unit params
|
|
2439
2439
|
* @returns {TradeAssetUnits} Returns the total units and depth of a trade asset
|
|
2440
2440
|
*/
|
|
2441
|
-
getTradeAssetUnits(
|
|
2442
|
-
return __awaiter(this,
|
|
2441
|
+
getTradeAssetUnits(_a) {
|
|
2442
|
+
return __awaiter(this, arguments, void 0, function* ({ asset, height }) {
|
|
2443
2443
|
const { units, depth } = yield this.thorchainCache.thornode.getTradeAssetUnits(xchainUtil.assetToString(asset), height);
|
|
2444
2444
|
const decimals = yield this.thorchainCache.midgardQuery.getDecimalForAsset(asset);
|
|
2445
2445
|
return {
|
|
@@ -2457,7 +2457,7 @@ class ThorchainQuery {
|
|
|
2457
2457
|
getTradeAssetsUnits(params) {
|
|
2458
2458
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2459
2459
|
const tradeAssetsUnits = yield this.thorchainCache.thornode.getTradeAssetsUnits(params === null || params === void 0 ? void 0 : params.height);
|
|
2460
|
-
const parseData = (
|
|
2460
|
+
const parseData = (_a) => __awaiter(this, [_a], void 0, function* ({ asset, units, depth }) {
|
|
2461
2461
|
const tradeAsset = xchainUtil.assetFromStringEx(asset);
|
|
2462
2462
|
const decimals = yield this.thorchainCache.midgardQuery.getDecimalForAsset(tradeAsset);
|
|
2463
2463
|
return {
|
|
@@ -2474,8 +2474,8 @@ class ThorchainQuery {
|
|
|
2474
2474
|
* @param {TradeAssetsUnitsParams} params Get trade asset unit params
|
|
2475
2475
|
* @returns {TradeAssetUnits[]} Returns the total units and depth for each trade asset
|
|
2476
2476
|
*/
|
|
2477
|
-
getAddressTradeAccounts(
|
|
2478
|
-
return __awaiter(this,
|
|
2477
|
+
getAddressTradeAccounts(_a) {
|
|
2478
|
+
return __awaiter(this, arguments, void 0, function* ({ address, height, }) {
|
|
2479
2479
|
const account = yield this.thorchainCache.thornode.getTradeAssetAccount(address, height);
|
|
2480
2480
|
const parseData = (tradeAssetInfo) => __awaiter(this, void 0, void 0, function* () {
|
|
2481
2481
|
const asset = xchainUtil.assetFromStringEx(tradeAssetInfo.asset);
|
|
@@ -2496,8 +2496,8 @@ class ThorchainQuery {
|
|
|
2496
2496
|
* @param {number} height Optional - Block height
|
|
2497
2497
|
* @returns Returns all trade accounts for an asset
|
|
2498
2498
|
*/
|
|
2499
|
-
getTradeAssetAccounts(
|
|
2500
|
-
return __awaiter(this,
|
|
2499
|
+
getTradeAssetAccounts(_a) {
|
|
2500
|
+
return __awaiter(this, arguments, void 0, function* ({ asset, height }) {
|
|
2501
2501
|
const accounts = yield this.thorchainCache.thornode.getTradeAssetAccounts(xchainUtil.assetToString(asset), height);
|
|
2502
2502
|
const decimals = yield this.thorchainCache.midgardQuery.getDecimalForAsset(asset);
|
|
2503
2503
|
return accounts.map((account) => {
|
|
@@ -2549,8 +2549,8 @@ class ThorchainQuery {
|
|
|
2549
2549
|
* @param {RunePoolProviderParams} params Get Rune pool provider position params
|
|
2550
2550
|
* @returns {RunePoolProvider} Rune pool provider position
|
|
2551
2551
|
*/
|
|
2552
|
-
getRunePoolProvider(
|
|
2553
|
-
return __awaiter(this,
|
|
2552
|
+
getRunePoolProvider(_a) {
|
|
2553
|
+
return __awaiter(this, arguments, void 0, function* ({ address, height }) {
|
|
2554
2554
|
const position = yield this.thorchainCache.thornode.getRunePoolProvider(address, height);
|
|
2555
2555
|
return {
|
|
2556
2556
|
address: position.rune_address,
|
|
@@ -2771,8 +2771,8 @@ class TransactionStage {
|
|
|
2771
2771
|
* @param progress - Transaction progress object.
|
|
2772
2772
|
*/
|
|
2773
2773
|
checkSwapProgress(txData, progress) {
|
|
2774
|
-
var _a, _b, _c, _d;
|
|
2775
2774
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2775
|
+
var _a, _b, _c, _d;
|
|
2776
2776
|
if (progress.inboundObserved) {
|
|
2777
2777
|
// Extract memo fields
|
|
2778
2778
|
const memo = (_a = txData.tx.tx.memo) !== null && _a !== void 0 ? _a : '';
|
|
@@ -2800,7 +2800,7 @@ class TransactionStage {
|
|
|
2800
2800
|
status: swapStatus,
|
|
2801
2801
|
expectedOutBlock,
|
|
2802
2802
|
expectedOutDate,
|
|
2803
|
-
expectedAmountOut: minimumAmountOut,
|
|
2803
|
+
expectedAmountOut: minimumAmountOut, // TODO call estimateSwap()
|
|
2804
2804
|
confirmations,
|
|
2805
2805
|
minimumAmountOut,
|
|
2806
2806
|
affliateFee,
|
|
@@ -2845,8 +2845,8 @@ class TransactionStage {
|
|
|
2845
2845
|
* @returns Promise<TXProgress> - Transaction progress object.
|
|
2846
2846
|
*/
|
|
2847
2847
|
determineObserved(txData) {
|
|
2848
|
-
var _a, _b, _c, _d;
|
|
2849
2848
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2849
|
+
var _a, _b, _c, _d;
|
|
2850
2850
|
const progress = {
|
|
2851
2851
|
txType: exports.TxType.Unknown,
|
|
2852
2852
|
};
|
|
@@ -2882,7 +2882,7 @@ class TransactionStage {
|
|
|
2882
2882
|
: yield this.blockToDate(assetIn.chain, txData);
|
|
2883
2883
|
progress.inboundObserved = {
|
|
2884
2884
|
status,
|
|
2885
|
-
date: dateObserved,
|
|
2885
|
+
date: dateObserved, // date observed?
|
|
2886
2886
|
block,
|
|
2887
2887
|
expectedConfirmationBlock: finalizeBlock,
|
|
2888
2888
|
expectedConfirmationDate,
|
|
@@ -2900,8 +2900,8 @@ class TransactionStage {
|
|
|
2900
2900
|
* @param progress - Transaction progress object.
|
|
2901
2901
|
*/
|
|
2902
2902
|
checkAddLpProgress(txData, progress) {
|
|
2903
|
-
var _a;
|
|
2904
2903
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2904
|
+
var _a;
|
|
2905
2905
|
if (progress.inboundObserved) {
|
|
2906
2906
|
// Extract memo fields
|
|
2907
2907
|
const memo = (_a = txData.tx.tx.memo) !== null && _a !== void 0 ? _a : '';
|
|
@@ -2932,8 +2932,8 @@ class TransactionStage {
|
|
|
2932
2932
|
* @param progress - Transaction progress object.
|
|
2933
2933
|
*/
|
|
2934
2934
|
checkWithdrawLpProgress(txData, progress) {
|
|
2935
|
-
var _a, _b;
|
|
2936
2935
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2936
|
+
var _a, _b;
|
|
2937
2937
|
if (progress.inboundObserved) {
|
|
2938
2938
|
// Extract memo fields
|
|
2939
2939
|
const memo = (_a = txData.tx.tx.memo) !== null && _a !== void 0 ? _a : '';
|
|
@@ -3002,8 +3002,8 @@ class TransactionStage {
|
|
|
3002
3002
|
* @param progress - Transaction progress object.
|
|
3003
3003
|
*/
|
|
3004
3004
|
checkWithdrawSaverProgress(txData, progress) {
|
|
3005
|
-
var _a;
|
|
3006
3005
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3006
|
+
var _a;
|
|
3007
3007
|
if (progress.inboundObserved) {
|
|
3008
3008
|
// Extract memo fields
|
|
3009
3009
|
const memo = (_a = txData.tx.tx.memo) !== null && _a !== void 0 ? _a : '';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xchainjs/xchain-thorchain-query",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Thorchain query module that is responsible for estimating swap calculations and add/remove liquidity for thorchain ",
|
|
6
6
|
"keywords": [
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"postversion": "git push --follow-tags"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@xchainjs/xchain-client": "2.0.
|
|
37
|
-
"@xchainjs/xchain-midgard-query": "2.0.
|
|
38
|
-
"@xchainjs/xchain-thornode": "1.0.
|
|
39
|
-
"@xchainjs/xchain-util": "2.0.
|
|
36
|
+
"@xchainjs/xchain-client": "2.0.6",
|
|
37
|
+
"@xchainjs/xchain-midgard-query": "2.0.6",
|
|
38
|
+
"@xchainjs/xchain-thornode": "1.0.5",
|
|
39
|
+
"@xchainjs/xchain-util": "2.0.4",
|
|
40
40
|
"axios": "1.8.4",
|
|
41
41
|
"axios-retry": "3.2.5",
|
|
42
42
|
"bignumber.js": "^9.0.0"
|