@xchainjs/xchain-thorchain-query 0.6.13 → 0.7.0
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.d.ts +0 -1
- package/lib/index.esm.js +2 -96
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +95 -190
- package/lib/index.js.map +1 -1
- package/lib/thorchain-cache.d.ts +1 -2
- package/lib/thorchain-checktx.d.ts +1 -2
- package/lib/thorchain-query.d.ts +1 -2
- package/lib/types.d.ts +1 -2
- package/lib/utils/utils.d.ts +1 -2
- package/package.json +6 -6
- package/lib/crypto-amount.d.ts +0 -37
package/lib/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ export * from './thorchain-query';
|
|
|
2
2
|
export * from './thorchain-checktx';
|
|
3
3
|
export * from './thorchain-cache';
|
|
4
4
|
export * from './liquidity-pool';
|
|
5
|
-
export * from './crypto-amount';
|
|
6
5
|
export * from './chain-defaults';
|
|
7
6
|
export * from './types';
|
|
8
7
|
export * from './utils';
|
package/lib/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { assetFromString, baseAmount, assetFromStringEx, assetToString, CryptoAmount, eqAsset, CachedValue, assetToBase, assetAmount } from '@xchainjs/xchain-util';
|
|
2
2
|
import { BigNumber } from 'bignumber.js';
|
|
3
3
|
import { MidgardQuery } from '@xchainjs/xchain-midgard-query';
|
|
4
4
|
import { Network } from '@xchainjs/xchain-client';
|
|
@@ -78,100 +78,6 @@ const DefaultChainAttributes = {
|
|
|
78
78
|
},
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
/**
|
|
82
|
-
* Utility Class to combine an amount (asset/base) with the Asset
|
|
83
|
-
*
|
|
84
|
-
*/
|
|
85
|
-
class CryptoAmount {
|
|
86
|
-
constructor(amount, asset) {
|
|
87
|
-
this.asset = asset;
|
|
88
|
-
this.baseAmount = amount;
|
|
89
|
-
}
|
|
90
|
-
plus(v) {
|
|
91
|
-
this.check(v);
|
|
92
|
-
const assetAmountResult = assetToBase(this.assetAmount.plus(v.assetAmount));
|
|
93
|
-
return new CryptoAmount(assetAmountResult, this.asset);
|
|
94
|
-
}
|
|
95
|
-
minus(v) {
|
|
96
|
-
this.check(v);
|
|
97
|
-
const assetAmountResult = assetToBase(this.assetAmount.minus(v.assetAmount));
|
|
98
|
-
return new CryptoAmount(assetAmountResult, this.asset);
|
|
99
|
-
}
|
|
100
|
-
times(v) {
|
|
101
|
-
this.check(v);
|
|
102
|
-
if (v instanceof CryptoAmount) {
|
|
103
|
-
const assetAmountResult = assetToBase(this.assetAmount.times(v.assetAmount));
|
|
104
|
-
return new CryptoAmount(assetAmountResult, this.asset);
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
const assetAmountResult = assetToBase(this.assetAmount.times(v));
|
|
108
|
-
return new CryptoAmount(assetAmountResult, this.asset);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
div(v) {
|
|
112
|
-
this.check(v);
|
|
113
|
-
if (v instanceof CryptoAmount) {
|
|
114
|
-
const assetAmountResult = assetToBase(this.assetAmount.div(v.assetAmount));
|
|
115
|
-
return new CryptoAmount(assetAmountResult, this.asset);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
const assetAmountResult = assetToBase(this.assetAmount.div(v));
|
|
119
|
-
return new CryptoAmount(assetAmountResult, this.asset);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
lt(v) {
|
|
123
|
-
this.check(v);
|
|
124
|
-
return this.assetAmount.lt(v.assetAmount);
|
|
125
|
-
}
|
|
126
|
-
lte(v) {
|
|
127
|
-
this.check(v);
|
|
128
|
-
return this.assetAmount.lte(v.assetAmount);
|
|
129
|
-
}
|
|
130
|
-
gt(v) {
|
|
131
|
-
this.check(v);
|
|
132
|
-
return this.assetAmount.gt(v.assetAmount);
|
|
133
|
-
}
|
|
134
|
-
gte(v) {
|
|
135
|
-
this.check(v);
|
|
136
|
-
return this.assetAmount.gte(v.assetAmount);
|
|
137
|
-
}
|
|
138
|
-
eq(v) {
|
|
139
|
-
this.check(v);
|
|
140
|
-
return this.assetAmount.eq(v.assetAmount);
|
|
141
|
-
}
|
|
142
|
-
formatedAssetString() {
|
|
143
|
-
return formatAssetAmountCurrency({
|
|
144
|
-
amount: this.assetAmount,
|
|
145
|
-
asset: this.asset,
|
|
146
|
-
trimZeros: true,
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
assetAmountFixedString() {
|
|
150
|
-
return this.assetAmount.amount().toFixed();
|
|
151
|
-
}
|
|
152
|
-
get assetAmount() {
|
|
153
|
-
return baseToAsset(this.baseAmount);
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* This guard protects against trying to perform math with different assets
|
|
157
|
-
*
|
|
158
|
-
* Example.
|
|
159
|
-
* const x = new CryptoAmount(assetAmount(1),AssetBTC)
|
|
160
|
-
* const y = new CryptoAmount(assetAmount(1),AssetETH)
|
|
161
|
-
*
|
|
162
|
-
* x.plus(y) <- will throw error "cannot perform math on 2 diff assets BTC.BTC ETH.ETH
|
|
163
|
-
*
|
|
164
|
-
* @param v - CryptoNumeric
|
|
165
|
-
*/
|
|
166
|
-
check(v) {
|
|
167
|
-
if (v instanceof CryptoAmount) {
|
|
168
|
-
if (!eqAsset(this.asset, v.asset)) {
|
|
169
|
-
throw Error(`cannot perform math on 2 diff assets ${assetToString(this.asset)} ${assetToString(v.asset)}`);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
81
|
/**
|
|
176
82
|
* Represent a Liquidity Pool in Thorchain
|
|
177
83
|
*/
|
|
@@ -2549,5 +2455,5 @@ class TransactionStage {
|
|
|
2549
2455
|
}
|
|
2550
2456
|
}
|
|
2551
2457
|
|
|
2552
|
-
export { AVAXChain, AddLpStatus, AddSaverStatus, AssetATOM, AssetAVAX, AssetBCH, AssetBNB, AssetBSC, AssetBTC, AssetDOGE, AssetETH, AssetLTC, AssetMAYA, AssetRuneNative, BCHChain, BNBChain, BSCChain, BTCChain,
|
|
2458
|
+
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, getLiquidityProtectionData, getLiquidityUnits, getPoolShare, getSlipOnLiquidity, isAssetRuneNative };
|
|
2553
2459
|
//# sourceMappingURL=index.esm.js.map
|