@xchainjs/xchain-mayachain-query 2.1.4 → 2.1.7
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 +15 -6
- package/lib/index.js +17 -5
- package/lib/mayachain-query.d.ts +2 -2
- package/lib/types.d.ts +18 -2
- package/lib/utils/const.d.ts +3 -0
- package/package.json +6 -6
package/lib/index.esm.js
CHANGED
|
@@ -232,6 +232,7 @@ class Mayanode {
|
|
|
232
232
|
const BtcAsset = assetFromStringEx('BTC.BTC');
|
|
233
233
|
const EthAsset = assetFromStringEx('ETH.ETH');
|
|
234
234
|
const CacaoAsset = assetFromStringEx('MAYA.CACAO');
|
|
235
|
+
const MayaAsset = assetFromStringEx('MAYA.MAYA');
|
|
235
236
|
const RuneAsset = assetFromStringEx('THOR.RUNE');
|
|
236
237
|
const DashAsset = assetFromStringEx('DASH.DASH');
|
|
237
238
|
const KujiraAsset = assetFromStringEx('KUJI.KUJI');
|
|
@@ -248,6 +249,8 @@ const ArbChain = 'ARB';
|
|
|
248
249
|
const XdrChain = 'XRD';
|
|
249
250
|
const ZecChain = 'ZEC';
|
|
250
251
|
const DEFAULT_MAYACHAIN_DECIMALS = 8;
|
|
252
|
+
const MAYA_DECIMAL = 4;
|
|
253
|
+
const CACAO_DECIMAL = 10;
|
|
251
254
|
|
|
252
255
|
const isCacaoAsset = (asset) => assetToString(asset) === assetToString(CacaoAsset);
|
|
253
256
|
const getBaseAmountWithDiffDecimals = (inputAmount, outDecimals) => {
|
|
@@ -659,6 +662,8 @@ class MayachainQuery {
|
|
|
659
662
|
name: MAYAName,
|
|
660
663
|
owner: details.owner,
|
|
661
664
|
expireBlockHeight: Number(details.expire),
|
|
665
|
+
preferredAsset: details.preferred_asset || '',
|
|
666
|
+
affiliateCollectorCacao: '0',
|
|
662
667
|
aliases: details.entries,
|
|
663
668
|
};
|
|
664
669
|
});
|
|
@@ -860,7 +865,7 @@ class MayachainQuery {
|
|
|
860
865
|
* @returns {QuoteMAYAName} Memo to make the update or the registration and the estimation of the operation
|
|
861
866
|
*/
|
|
862
867
|
estimateMAYAName(_a) {
|
|
863
|
-
return __awaiter(this, arguments, void 0, function* ({ name, owner, isUpdate, expiry, chain, chainAddress, }) {
|
|
868
|
+
return __awaiter(this, arguments, void 0, function* ({ name, owner, isUpdate, expiry, chain, chainAddress, preferredAsset, }) {
|
|
864
869
|
const details = yield this.getMAYANameDetails(name);
|
|
865
870
|
if (!details && isUpdate) {
|
|
866
871
|
throw Error('Can not update an unregistered MAYAName');
|
|
@@ -881,11 +886,11 @@ class MayachainQuery {
|
|
|
881
886
|
const oneTimeFee = isUpdate
|
|
882
887
|
? baseAmount(0, assetDecimals[assetToString(CacaoAsset)])
|
|
883
888
|
: baseAmount(constantsDetails['TNSREGISTERFEE'], assetDecimals[assetToString(CacaoAsset)]);
|
|
884
|
-
const totalFeePerBlock = baseAmount(constantsDetails['TNSFEEPERBLOCK']).times(numberOfBlocksToAddToExpiry > 0 ? numberOfBlocksToAddToExpiry : 0);
|
|
889
|
+
const totalFeePerBlock = baseAmount(constantsDetails['TNSFEEPERBLOCK'], assetDecimals[assetToString(CacaoAsset)]).times(numberOfBlocksToAddToExpiry > 0 ? numberOfBlocksToAddToExpiry : 0);
|
|
885
890
|
const txFee = baseAmount(constantsDetails['NATIVETRANSACTIONFEE'], assetDecimals[assetToString(CacaoAsset)]);
|
|
886
891
|
return {
|
|
887
892
|
value: new AssetCryptoAmount(oneTimeFee.plus(totalFeePerBlock).plus(txFee), CacaoAsset),
|
|
888
|
-
memo: `~:${name}:${isUpdate ? chain || (details === null || details === void 0 ? void 0 : details.aliases[0].chain) : chain}:${isUpdate ? chainAddress || (details === null || details === void 0 ? void 0 : details.aliases[0].address) : chainAddress}:${isUpdate ? owner || (details === null || details === void 0 ? void 0 : details.owner) : owner}:MAYA.CACAO`,
|
|
893
|
+
memo: `~:${name}:${isUpdate ? chain || (details === null || details === void 0 ? void 0 : details.aliases[0].chain) : chain}:${isUpdate ? chainAddress || (details === null || details === void 0 ? void 0 : details.aliases[0].address) : chainAddress}:${isUpdate ? owner || (details === null || details === void 0 ? void 0 : details.owner) : owner}:${preferredAsset ? assetToString(preferredAsset) : 'MAYA.CACAO'}`,
|
|
889
894
|
};
|
|
890
895
|
});
|
|
891
896
|
}
|
|
@@ -967,11 +972,15 @@ class MayachainQuery {
|
|
|
967
972
|
/**
|
|
968
973
|
* Get the hardcoded decimal precision for quote calculations
|
|
969
974
|
* @param asset The asset to get decimals for
|
|
970
|
-
* @returns 10 for Cacao, 8 for other assets (used in quote calculations)
|
|
975
|
+
* @returns 10 for Cacao, 4 for Maya, 8 for other assets (used in quote calculations)
|
|
971
976
|
*/
|
|
972
977
|
getQuoteAssetDecimals(asset) {
|
|
973
|
-
|
|
978
|
+
if (eqAsset(asset, CacaoAsset))
|
|
979
|
+
return CACAO_DECIMAL;
|
|
980
|
+
if (eqAsset(asset, MayaAsset))
|
|
981
|
+
return MAYA_DECIMAL;
|
|
982
|
+
return DEFAULT_MAYACHAIN_DECIMALS;
|
|
974
983
|
}
|
|
975
984
|
}
|
|
976
985
|
|
|
977
|
-
export { ArbAsset, ArbChain, BtcAsset, BtcChain, CacaoAsset, DEFAULT_MAYACHAIN_DECIMALS, DashAsset, DashChain, EthAsset, EthChain, KujiraAsset, KujiraChain, MayaChain, MayachainCache, MayachainQuery, Mayanode, RuneAsset, ThorChain, XdrAsset, XdrChain, ZecAsset, ZecChain, getBaseAmountWithDiffDecimals, getCryptoAmountWithNotation, isCacaoAsset };
|
|
986
|
+
export { ArbAsset, ArbChain, BtcAsset, BtcChain, CACAO_DECIMAL, CacaoAsset, DEFAULT_MAYACHAIN_DECIMALS, DashAsset, DashChain, EthAsset, EthChain, KujiraAsset, KujiraChain, MAYA_DECIMAL, MayaAsset, MayaChain, MayachainCache, MayachainQuery, Mayanode, RuneAsset, ThorChain, XdrAsset, XdrChain, ZecAsset, ZecChain, getBaseAmountWithDiffDecimals, getCryptoAmountWithNotation, isCacaoAsset };
|
package/lib/index.js
CHANGED
|
@@ -240,6 +240,7 @@ class Mayanode {
|
|
|
240
240
|
const BtcAsset = xchainUtil.assetFromStringEx('BTC.BTC');
|
|
241
241
|
const EthAsset = xchainUtil.assetFromStringEx('ETH.ETH');
|
|
242
242
|
const CacaoAsset = xchainUtil.assetFromStringEx('MAYA.CACAO');
|
|
243
|
+
const MayaAsset = xchainUtil.assetFromStringEx('MAYA.MAYA');
|
|
243
244
|
const RuneAsset = xchainUtil.assetFromStringEx('THOR.RUNE');
|
|
244
245
|
const DashAsset = xchainUtil.assetFromStringEx('DASH.DASH');
|
|
245
246
|
const KujiraAsset = xchainUtil.assetFromStringEx('KUJI.KUJI');
|
|
@@ -256,6 +257,8 @@ const ArbChain = 'ARB';
|
|
|
256
257
|
const XdrChain = 'XRD';
|
|
257
258
|
const ZecChain = 'ZEC';
|
|
258
259
|
const DEFAULT_MAYACHAIN_DECIMALS = 8;
|
|
260
|
+
const MAYA_DECIMAL = 4;
|
|
261
|
+
const CACAO_DECIMAL = 10;
|
|
259
262
|
|
|
260
263
|
const isCacaoAsset = (asset) => xchainUtil.assetToString(asset) === xchainUtil.assetToString(CacaoAsset);
|
|
261
264
|
const getBaseAmountWithDiffDecimals = (inputAmount, outDecimals) => {
|
|
@@ -667,6 +670,8 @@ class MayachainQuery {
|
|
|
667
670
|
name: MAYAName,
|
|
668
671
|
owner: details.owner,
|
|
669
672
|
expireBlockHeight: Number(details.expire),
|
|
673
|
+
preferredAsset: details.preferred_asset || '',
|
|
674
|
+
affiliateCollectorCacao: '0',
|
|
670
675
|
aliases: details.entries,
|
|
671
676
|
};
|
|
672
677
|
});
|
|
@@ -868,7 +873,7 @@ class MayachainQuery {
|
|
|
868
873
|
* @returns {QuoteMAYAName} Memo to make the update or the registration and the estimation of the operation
|
|
869
874
|
*/
|
|
870
875
|
estimateMAYAName(_a) {
|
|
871
|
-
return __awaiter(this, arguments, void 0, function* ({ name, owner, isUpdate, expiry, chain, chainAddress, }) {
|
|
876
|
+
return __awaiter(this, arguments, void 0, function* ({ name, owner, isUpdate, expiry, chain, chainAddress, preferredAsset, }) {
|
|
872
877
|
const details = yield this.getMAYANameDetails(name);
|
|
873
878
|
if (!details && isUpdate) {
|
|
874
879
|
throw Error('Can not update an unregistered MAYAName');
|
|
@@ -889,11 +894,11 @@ class MayachainQuery {
|
|
|
889
894
|
const oneTimeFee = isUpdate
|
|
890
895
|
? xchainUtil.baseAmount(0, assetDecimals[xchainUtil.assetToString(CacaoAsset)])
|
|
891
896
|
: xchainUtil.baseAmount(constantsDetails['TNSREGISTERFEE'], assetDecimals[xchainUtil.assetToString(CacaoAsset)]);
|
|
892
|
-
const totalFeePerBlock = xchainUtil.baseAmount(constantsDetails['TNSFEEPERBLOCK']).times(numberOfBlocksToAddToExpiry > 0 ? numberOfBlocksToAddToExpiry : 0);
|
|
897
|
+
const totalFeePerBlock = xchainUtil.baseAmount(constantsDetails['TNSFEEPERBLOCK'], assetDecimals[xchainUtil.assetToString(CacaoAsset)]).times(numberOfBlocksToAddToExpiry > 0 ? numberOfBlocksToAddToExpiry : 0);
|
|
893
898
|
const txFee = xchainUtil.baseAmount(constantsDetails['NATIVETRANSACTIONFEE'], assetDecimals[xchainUtil.assetToString(CacaoAsset)]);
|
|
894
899
|
return {
|
|
895
900
|
value: new xchainUtil.AssetCryptoAmount(oneTimeFee.plus(totalFeePerBlock).plus(txFee), CacaoAsset),
|
|
896
|
-
memo: `~:${name}:${isUpdate ? chain || (details === null || details === void 0 ? void 0 : details.aliases[0].chain) : chain}:${isUpdate ? chainAddress || (details === null || details === void 0 ? void 0 : details.aliases[0].address) : chainAddress}:${isUpdate ? owner || (details === null || details === void 0 ? void 0 : details.owner) : owner}:MAYA.CACAO`,
|
|
901
|
+
memo: `~:${name}:${isUpdate ? chain || (details === null || details === void 0 ? void 0 : details.aliases[0].chain) : chain}:${isUpdate ? chainAddress || (details === null || details === void 0 ? void 0 : details.aliases[0].address) : chainAddress}:${isUpdate ? owner || (details === null || details === void 0 ? void 0 : details.owner) : owner}:${preferredAsset ? xchainUtil.assetToString(preferredAsset) : 'MAYA.CACAO'}`,
|
|
897
902
|
};
|
|
898
903
|
});
|
|
899
904
|
}
|
|
@@ -975,10 +980,14 @@ class MayachainQuery {
|
|
|
975
980
|
/**
|
|
976
981
|
* Get the hardcoded decimal precision for quote calculations
|
|
977
982
|
* @param asset The asset to get decimals for
|
|
978
|
-
* @returns 10 for Cacao, 8 for other assets (used in quote calculations)
|
|
983
|
+
* @returns 10 for Cacao, 4 for Maya, 8 for other assets (used in quote calculations)
|
|
979
984
|
*/
|
|
980
985
|
getQuoteAssetDecimals(asset) {
|
|
981
|
-
|
|
986
|
+
if (xchainUtil.eqAsset(asset, CacaoAsset))
|
|
987
|
+
return CACAO_DECIMAL;
|
|
988
|
+
if (xchainUtil.eqAsset(asset, MayaAsset))
|
|
989
|
+
return MAYA_DECIMAL;
|
|
990
|
+
return DEFAULT_MAYACHAIN_DECIMALS;
|
|
982
991
|
}
|
|
983
992
|
}
|
|
984
993
|
|
|
@@ -986,6 +995,7 @@ exports.ArbAsset = ArbAsset;
|
|
|
986
995
|
exports.ArbChain = ArbChain;
|
|
987
996
|
exports.BtcAsset = BtcAsset;
|
|
988
997
|
exports.BtcChain = BtcChain;
|
|
998
|
+
exports.CACAO_DECIMAL = CACAO_DECIMAL;
|
|
989
999
|
exports.CacaoAsset = CacaoAsset;
|
|
990
1000
|
exports.DEFAULT_MAYACHAIN_DECIMALS = DEFAULT_MAYACHAIN_DECIMALS;
|
|
991
1001
|
exports.DashAsset = DashAsset;
|
|
@@ -994,6 +1004,8 @@ exports.EthAsset = EthAsset;
|
|
|
994
1004
|
exports.EthChain = EthChain;
|
|
995
1005
|
exports.KujiraAsset = KujiraAsset;
|
|
996
1006
|
exports.KujiraChain = KujiraChain;
|
|
1007
|
+
exports.MAYA_DECIMAL = MAYA_DECIMAL;
|
|
1008
|
+
exports.MayaAsset = MayaAsset;
|
|
997
1009
|
exports.MayaChain = MayaChain;
|
|
998
1010
|
exports.MayachainCache = MayachainCache;
|
|
999
1011
|
exports.MayachainQuery = MayachainQuery;
|
package/lib/mayachain-query.d.ts
CHANGED
|
@@ -97,7 +97,7 @@ export declare class MayachainQuery {
|
|
|
97
97
|
* @param {QuoteMAYANameParams} params Params to make the update or the registration
|
|
98
98
|
* @returns {QuoteMAYAName} Memo to make the update or the registration and the estimation of the operation
|
|
99
99
|
*/
|
|
100
|
-
estimateMAYAName({ name, owner, isUpdate, expiry, chain, chainAddress, }: QuoteMAYANameParams): Promise<QuoteMAYAName>;
|
|
100
|
+
estimateMAYAName({ name, owner, isUpdate, expiry, chain, chainAddress, preferredAsset, }: QuoteMAYANameParams): Promise<QuoteMAYAName>;
|
|
101
101
|
/**
|
|
102
102
|
* Get trade asset units
|
|
103
103
|
* @param {TradeAssetUnitsParams} params Trade asset units params
|
|
@@ -125,7 +125,7 @@ export declare class MayachainQuery {
|
|
|
125
125
|
/**
|
|
126
126
|
* Get the hardcoded decimal precision for quote calculations
|
|
127
127
|
* @param asset The asset to get decimals for
|
|
128
|
-
* @returns 10 for Cacao, 8 for other assets (used in quote calculations)
|
|
128
|
+
* @returns 10 for Cacao, 4 for Maya, 8 for other assets (used in quote calculations)
|
|
129
129
|
*/
|
|
130
130
|
private getQuoteAssetDecimals;
|
|
131
131
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TxHash } from '@xchainjs/xchain-client';
|
|
2
|
-
import { Address, Asset, AssetCryptoAmount, Chain, CryptoAmount, SynthAsset, TokenAsset, TradeAsset, TradeCryptoAmount } from '@xchainjs/xchain-util';
|
|
2
|
+
import { Address, Asset, AssetCryptoAmount, Chain, CryptoAmount, SecuredAsset, SynthAsset, TokenAsset, TradeAsset, TradeCryptoAmount } from '@xchainjs/xchain-util';
|
|
3
3
|
import type BigNumber from 'bignumber.js';
|
|
4
|
-
export type CompatibleAsset = Asset | TokenAsset | SynthAsset | TradeAsset;
|
|
4
|
+
export type CompatibleAsset = Asset | TokenAsset | SynthAsset | TradeAsset | SecuredAsset;
|
|
5
5
|
/**
|
|
6
6
|
* Represents fees associated with a swap.
|
|
7
7
|
*/
|
|
@@ -167,6 +167,14 @@ export type MAYANameDetails = {
|
|
|
167
167
|
* The owner of the MAYAName
|
|
168
168
|
*/
|
|
169
169
|
owner: string;
|
|
170
|
+
/**
|
|
171
|
+
* The preferred asset
|
|
172
|
+
*/
|
|
173
|
+
preferredAsset?: string;
|
|
174
|
+
/**
|
|
175
|
+
* The affiliate collector CACAO
|
|
176
|
+
*/
|
|
177
|
+
affiliateCollectorCacao?: string;
|
|
170
178
|
/**
|
|
171
179
|
* List of MAYAName aliases
|
|
172
180
|
*/
|
|
@@ -196,6 +204,10 @@ export type RegisterMAYAName = {
|
|
|
196
204
|
* Address of the chain provided to create the alias of the MAYAName
|
|
197
205
|
*/
|
|
198
206
|
chainAddress: Address;
|
|
207
|
+
/**
|
|
208
|
+
* Preferred asset for the MAYAName owner to receive fees in
|
|
209
|
+
*/
|
|
210
|
+
preferredAsset?: Asset;
|
|
199
211
|
};
|
|
200
212
|
/**
|
|
201
213
|
* Update MAYAName parameters
|
|
@@ -221,6 +233,10 @@ export type UpdateMAYAName = {
|
|
|
221
233
|
* Address of the chain provided to update the alias of the MAYAName, if not provided, memo response will have the address of the chain returned
|
|
222
234
|
*/
|
|
223
235
|
chainAddress?: Address;
|
|
236
|
+
/**
|
|
237
|
+
* Preferred asset for the MAYAName owner to receive fees in
|
|
238
|
+
*/
|
|
239
|
+
preferredAsset?: Asset;
|
|
224
240
|
};
|
|
225
241
|
export type QuoteMAYANameParams = (RegisterMAYAName & {
|
|
226
242
|
isUpdate?: false;
|
package/lib/utils/const.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Asset } from '@xchainjs/xchain-util';
|
|
|
2
2
|
export declare const BtcAsset: Asset;
|
|
3
3
|
export declare const EthAsset: Asset;
|
|
4
4
|
export declare const CacaoAsset: Asset;
|
|
5
|
+
export declare const MayaAsset: Asset;
|
|
5
6
|
export declare const RuneAsset: Asset;
|
|
6
7
|
export declare const DashAsset: Asset;
|
|
7
8
|
export declare const KujiraAsset: Asset;
|
|
@@ -18,3 +19,5 @@ export declare const ArbChain = "ARB";
|
|
|
18
19
|
export declare const XdrChain = "XRD";
|
|
19
20
|
export declare const ZecChain = "ZEC";
|
|
20
21
|
export declare const DEFAULT_MAYACHAIN_DECIMALS = 8;
|
|
22
|
+
export declare const MAYA_DECIMAL = 4;
|
|
23
|
+
export declare const CACAO_DECIMAL = 10;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xchainjs/xchain-mayachain-query",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Mayachain query module that is responsible for estimating swap calculations and add/remove liquidity for thorchain",
|
|
6
6
|
"keywords": [
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"postversion": "git push --follow-tags"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@xchainjs/xchain-client": "2.0.
|
|
37
|
-
"@xchainjs/xchain-mayamidgard": "1.0
|
|
38
|
-
"@xchainjs/xchain-mayamidgard-query": "1.0.
|
|
39
|
-
"@xchainjs/xchain-mayanode": "1.
|
|
36
|
+
"@xchainjs/xchain-client": "2.0.10",
|
|
37
|
+
"@xchainjs/xchain-mayamidgard": "1.1.0",
|
|
38
|
+
"@xchainjs/xchain-mayamidgard-query": "1.0.12",
|
|
39
|
+
"@xchainjs/xchain-mayanode": "1.2.0",
|
|
40
40
|
"@xchainjs/xchain-util": "2.0.5",
|
|
41
|
-
"axios": "1.
|
|
41
|
+
"axios": "1.13.5",
|
|
42
42
|
"axios-retry": "3.2.5",
|
|
43
43
|
"bignumber.js": "^9.1.2"
|
|
44
44
|
},
|