@xchainjs/xchain-thorchain-amm 0.7.8 → 0.7.13
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 +27 -33
- package/lib/index.js +16 -22
- package/lib/wallet.d.ts +28 -2
- package/package.json +13 -13
package/lib/index.esm.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Client as Client$9, defaultAvaxParams } from '@xchainjs/xchain-avax';
|
|
2
|
-
import { Client as Client$5 } from '@xchainjs/xchain-binance';
|
|
3
|
-
import { Client as Client$1, BTCChain } from '@xchainjs/xchain-bitcoin';
|
|
4
|
-
import { Client } from '@xchainjs/xchain-bitcoincash';
|
|
5
|
-
import { Client as Client$a, defaultBscParams } from '@xchainjs/xchain-bsc';
|
|
1
|
+
import { Client as Client$9, defaultAvaxParams, AVAXChain } from '@xchainjs/xchain-avax';
|
|
2
|
+
import { Client as Client$5, BNBChain } from '@xchainjs/xchain-binance';
|
|
3
|
+
import { Client as Client$1, defaultBTCParams, BTCChain } from '@xchainjs/xchain-bitcoin';
|
|
4
|
+
import { Client, defaultBchParams, BCHChain } from '@xchainjs/xchain-bitcoincash';
|
|
5
|
+
import { Client as Client$a, defaultBscParams, BSCChain } from '@xchainjs/xchain-bsc';
|
|
6
6
|
import { FeeOption } from '@xchainjs/xchain-client';
|
|
7
|
-
import { Client as Client$6 } from '@xchainjs/xchain-cosmos';
|
|
8
|
-
import { Client as Client$2 } from '@xchainjs/xchain-doge';
|
|
9
|
-
import { Client as Client$8, defaultEthParams } from '@xchainjs/xchain-ethereum';
|
|
10
|
-
import { Client as Client$3 } from '@xchainjs/xchain-litecoin';
|
|
11
|
-
import { Client as Client$7 } from '@xchainjs/xchain-mayachain';
|
|
7
|
+
import { Client as Client$6, GAIAChain } from '@xchainjs/xchain-cosmos';
|
|
8
|
+
import { Client as Client$2, defaultDogeParams, DOGEChain } from '@xchainjs/xchain-doge';
|
|
9
|
+
import { Client as Client$8, defaultEthParams, ETHChain } from '@xchainjs/xchain-ethereum';
|
|
10
|
+
import { Client as Client$3, defaultLtcParams, LTCChain } from '@xchainjs/xchain-litecoin';
|
|
11
|
+
import { Client as Client$7, MAYAChain } from '@xchainjs/xchain-mayachain';
|
|
12
12
|
import { Client as Client$4, THORChain } from '@xchainjs/xchain-thorchain';
|
|
13
13
|
import { eqAsset, getContractAddressFromAsset, baseAmount, assetFromString } from '@xchainjs/xchain-util';
|
|
14
|
-
import { abi, MAX_APPROVAL } from '@xchainjs/xchain-evm';
|
|
14
|
+
import { Protocol, abi, MAX_APPROVAL } from '@xchainjs/xchain-evm';
|
|
15
15
|
import { ethers } from 'ethers';
|
|
16
16
|
import { ThorchainQuery } from '@xchainjs/xchain-thorchain-query';
|
|
17
17
|
|
|
@@ -68,15 +68,16 @@ class EvmHelper {
|
|
|
68
68
|
throw new Error('Vault address is not defined');
|
|
69
69
|
}
|
|
70
70
|
const address = this.client.getAddress(params.walletIndex);
|
|
71
|
-
const gasPrice = yield this.evmClient.estimateGasPrices();
|
|
71
|
+
const gasPrice = yield this.evmClient.estimateGasPrices(Protocol.THORCHAIN);
|
|
72
72
|
if (eqAsset(params.asset, this.evmClient.config.gasAsset)) {
|
|
73
73
|
// simple transfer
|
|
74
|
-
return yield this.
|
|
74
|
+
return yield this.evmClient.transfer({
|
|
75
75
|
walletIndex: params.walletIndex || 0,
|
|
76
76
|
asset: params.asset,
|
|
77
77
|
amount: params.amount,
|
|
78
78
|
recipient: inboundAsgard.address,
|
|
79
79
|
memo: params.memo,
|
|
80
|
+
gasPrice: gasPrice.fast,
|
|
80
81
|
});
|
|
81
82
|
}
|
|
82
83
|
else {
|
|
@@ -145,32 +146,25 @@ class Wallet {
|
|
|
145
146
|
*
|
|
146
147
|
* @param phrase - mnemonic phrase
|
|
147
148
|
* @param thorchainCache - an instance of the ThorchainCache (could be pointing to stagenet,testnet,mainnet)
|
|
149
|
+
* @param chainConfigs - Config by chain
|
|
148
150
|
* @returns Wallet
|
|
149
151
|
*/
|
|
150
|
-
constructor(phrase, thorchainQuery) {
|
|
152
|
+
constructor(phrase, thorchainQuery, chainConfigs = {}) {
|
|
151
153
|
this.thorchainQuery = thorchainQuery;
|
|
152
154
|
const settings = { network: this.thorchainQuery.thorchainCache.midgardQuery.midgardCache.midgard.network, phrase };
|
|
153
155
|
this.clients = {
|
|
154
|
-
BCH: new Client(),
|
|
155
|
-
BTC: new Client$1(),
|
|
156
|
-
DOGE: new Client$2(),
|
|
157
|
-
LTC: new Client$3(),
|
|
158
|
-
THOR: new Client$4(settings),
|
|
159
|
-
BNB: new Client$5(settings),
|
|
160
|
-
GAIA: new Client$6(settings),
|
|
161
|
-
MAYA: new Client$7(settings),
|
|
162
|
-
ETH: new Client$8(Object.assign(Object.assign({}, defaultEthParams),
|
|
163
|
-
AVAX: new Client$9(Object.assign(Object.assign({}, defaultAvaxParams),
|
|
164
|
-
BSC: new Client$a(Object.assign(Object.assign({}, defaultBscParams),
|
|
156
|
+
BCH: new Client(Object.assign(Object.assign(Object.assign({}, defaultBchParams), chainConfigs[BCHChain]), settings)),
|
|
157
|
+
BTC: new Client$1(Object.assign(Object.assign(Object.assign({}, defaultBTCParams), chainConfigs[BTCChain]), settings)),
|
|
158
|
+
DOGE: new Client$2(Object.assign(Object.assign(Object.assign({}, defaultDogeParams), chainConfigs[DOGEChain]), settings)),
|
|
159
|
+
LTC: new Client$3(Object.assign(Object.assign(Object.assign({}, defaultLtcParams), chainConfigs[LTCChain]), settings)),
|
|
160
|
+
THOR: new Client$4(Object.assign(Object.assign({}, chainConfigs[THORChain]), settings)),
|
|
161
|
+
BNB: new Client$5(Object.assign(Object.assign({}, chainConfigs[BNBChain]), settings)),
|
|
162
|
+
GAIA: new Client$6(Object.assign(Object.assign({}, chainConfigs[GAIAChain]), settings)),
|
|
163
|
+
MAYA: new Client$7(Object.assign(Object.assign({}, chainConfigs[MAYAChain]), settings)),
|
|
164
|
+
ETH: new Client$8(Object.assign(Object.assign(Object.assign({}, defaultEthParams), chainConfigs[ETHChain]), settings)),
|
|
165
|
+
AVAX: new Client$9(Object.assign(Object.assign(Object.assign({}, defaultAvaxParams), chainConfigs[AVAXChain]), settings)),
|
|
166
|
+
BSC: new Client$a(Object.assign(Object.assign(Object.assign({}, defaultBscParams), chainConfigs[BSCChain]), settings)),
|
|
165
167
|
};
|
|
166
|
-
this.clients.BCH.setNetwork(settings.network);
|
|
167
|
-
this.clients.BCH.setPhrase(settings.phrase, 0);
|
|
168
|
-
this.clients.BTC.setNetwork(settings.network);
|
|
169
|
-
this.clients.BTC.setPhrase(settings.phrase, 0);
|
|
170
|
-
this.clients.DOGE.setNetwork(settings.network);
|
|
171
|
-
this.clients.DOGE.setPhrase(settings.phrase, 0);
|
|
172
|
-
this.clients.LTC.setNetwork(settings.network);
|
|
173
|
-
this.clients.LTC.setPhrase(settings.phrase, 0);
|
|
174
168
|
this.evmHelpers = {
|
|
175
169
|
ETH: new EvmHelper(this.clients.ETH, this.thorchainQuery.thorchainCache),
|
|
176
170
|
BSC: new EvmHelper(this.clients.BSC, this.thorchainQuery.thorchainCache),
|
package/lib/index.js
CHANGED
|
@@ -72,15 +72,16 @@ class EvmHelper {
|
|
|
72
72
|
throw new Error('Vault address is not defined');
|
|
73
73
|
}
|
|
74
74
|
const address = this.client.getAddress(params.walletIndex);
|
|
75
|
-
const gasPrice = yield this.evmClient.estimateGasPrices();
|
|
75
|
+
const gasPrice = yield this.evmClient.estimateGasPrices(xchainEvm.Protocol.THORCHAIN);
|
|
76
76
|
if (xchainUtil.eqAsset(params.asset, this.evmClient.config.gasAsset)) {
|
|
77
77
|
// simple transfer
|
|
78
|
-
return yield this.
|
|
78
|
+
return yield this.evmClient.transfer({
|
|
79
79
|
walletIndex: params.walletIndex || 0,
|
|
80
80
|
asset: params.asset,
|
|
81
81
|
amount: params.amount,
|
|
82
82
|
recipient: inboundAsgard.address,
|
|
83
83
|
memo: params.memo,
|
|
84
|
+
gasPrice: gasPrice.fast,
|
|
84
85
|
});
|
|
85
86
|
}
|
|
86
87
|
else {
|
|
@@ -149,32 +150,25 @@ class Wallet {
|
|
|
149
150
|
*
|
|
150
151
|
* @param phrase - mnemonic phrase
|
|
151
152
|
* @param thorchainCache - an instance of the ThorchainCache (could be pointing to stagenet,testnet,mainnet)
|
|
153
|
+
* @param chainConfigs - Config by chain
|
|
152
154
|
* @returns Wallet
|
|
153
155
|
*/
|
|
154
|
-
constructor(phrase, thorchainQuery) {
|
|
156
|
+
constructor(phrase, thorchainQuery, chainConfigs = {}) {
|
|
155
157
|
this.thorchainQuery = thorchainQuery;
|
|
156
158
|
const settings = { network: this.thorchainQuery.thorchainCache.midgardQuery.midgardCache.midgard.network, phrase };
|
|
157
159
|
this.clients = {
|
|
158
|
-
BCH: new xchainBitcoincash.Client(),
|
|
159
|
-
BTC: new xchainBitcoin.Client(),
|
|
160
|
-
DOGE: new xchainDoge.Client(),
|
|
161
|
-
LTC: new xchainLitecoin.Client(),
|
|
162
|
-
THOR: new xchainThorchain.Client(settings),
|
|
163
|
-
BNB: new xchainBinance.Client(settings),
|
|
164
|
-
GAIA: new xchainCosmos.Client(settings),
|
|
165
|
-
MAYA: new xchainMayachain.Client(settings),
|
|
166
|
-
ETH: new xchainEthereum.Client(Object.assign(Object.assign({}, xchainEthereum.defaultEthParams),
|
|
167
|
-
AVAX: new xchainAvax.Client(Object.assign(Object.assign({}, xchainAvax.defaultAvaxParams),
|
|
168
|
-
BSC: new xchainBsc.Client(Object.assign(Object.assign({}, xchainBsc.defaultBscParams),
|
|
160
|
+
BCH: new xchainBitcoincash.Client(Object.assign(Object.assign(Object.assign({}, xchainBitcoincash.defaultBchParams), chainConfigs[xchainBitcoincash.BCHChain]), settings)),
|
|
161
|
+
BTC: new xchainBitcoin.Client(Object.assign(Object.assign(Object.assign({}, xchainBitcoin.defaultBTCParams), chainConfigs[xchainBitcoin.BTCChain]), settings)),
|
|
162
|
+
DOGE: new xchainDoge.Client(Object.assign(Object.assign(Object.assign({}, xchainDoge.defaultDogeParams), chainConfigs[xchainDoge.DOGEChain]), settings)),
|
|
163
|
+
LTC: new xchainLitecoin.Client(Object.assign(Object.assign(Object.assign({}, xchainLitecoin.defaultLtcParams), chainConfigs[xchainLitecoin.LTCChain]), settings)),
|
|
164
|
+
THOR: new xchainThorchain.Client(Object.assign(Object.assign({}, chainConfigs[xchainThorchain.THORChain]), settings)),
|
|
165
|
+
BNB: new xchainBinance.Client(Object.assign(Object.assign({}, chainConfigs[xchainBinance.BNBChain]), settings)),
|
|
166
|
+
GAIA: new xchainCosmos.Client(Object.assign(Object.assign({}, chainConfigs[xchainCosmos.GAIAChain]), settings)),
|
|
167
|
+
MAYA: new xchainMayachain.Client(Object.assign(Object.assign({}, chainConfigs[xchainMayachain.MAYAChain]), settings)),
|
|
168
|
+
ETH: new xchainEthereum.Client(Object.assign(Object.assign(Object.assign({}, xchainEthereum.defaultEthParams), chainConfigs[xchainEthereum.ETHChain]), settings)),
|
|
169
|
+
AVAX: new xchainAvax.Client(Object.assign(Object.assign(Object.assign({}, xchainAvax.defaultAvaxParams), chainConfigs[xchainAvax.AVAXChain]), settings)),
|
|
170
|
+
BSC: new xchainBsc.Client(Object.assign(Object.assign(Object.assign({}, xchainBsc.defaultBscParams), chainConfigs[xchainBsc.BSCChain]), settings)),
|
|
169
171
|
};
|
|
170
|
-
this.clients.BCH.setNetwork(settings.network);
|
|
171
|
-
this.clients.BCH.setPhrase(settings.phrase, 0);
|
|
172
|
-
this.clients.BTC.setNetwork(settings.network);
|
|
173
|
-
this.clients.BTC.setPhrase(settings.phrase, 0);
|
|
174
|
-
this.clients.DOGE.setNetwork(settings.network);
|
|
175
|
-
this.clients.DOGE.setPhrase(settings.phrase, 0);
|
|
176
|
-
this.clients.LTC.setNetwork(settings.network);
|
|
177
|
-
this.clients.LTC.setPhrase(settings.phrase, 0);
|
|
178
172
|
this.evmHelpers = {
|
|
179
173
|
ETH: new EvmHelper(this.clients.ETH, this.thorchainQuery.thorchainCache),
|
|
180
174
|
BSC: new EvmHelper(this.clients.BSC, this.thorchainQuery.thorchainCache),
|
package/lib/wallet.d.ts
CHANGED
|
@@ -1,9 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AVAXChain } from '@xchainjs/xchain-avax';
|
|
2
|
+
import { BNBChain } from '@xchainjs/xchain-binance';
|
|
3
|
+
import { BTCChain } from '@xchainjs/xchain-bitcoin';
|
|
4
|
+
import { BCHChain } from '@xchainjs/xchain-bitcoincash';
|
|
5
|
+
import { BSCChain } from '@xchainjs/xchain-bsc';
|
|
6
|
+
import { Network, UtxoClientParams, XChainClient, XChainClientParams } from '@xchainjs/xchain-client';
|
|
7
|
+
import { GAIAChain } from '@xchainjs/xchain-cosmos';
|
|
8
|
+
import { DOGEChain } from '@xchainjs/xchain-doge';
|
|
9
|
+
import { ETHChain } from '@xchainjs/xchain-ethereum';
|
|
10
|
+
import { EVMClientParams } from '@xchainjs/xchain-evm';
|
|
11
|
+
import { LTCChain } from '@xchainjs/xchain-litecoin';
|
|
12
|
+
import { MAYAChain, MayachainClientParams } from '@xchainjs/xchain-mayachain';
|
|
13
|
+
import { THORChain, ThorchainClientParams } from '@xchainjs/xchain-thorchain';
|
|
2
14
|
import { CryptoAmount, ThorchainQuery } from '@xchainjs/xchain-thorchain-query';
|
|
3
15
|
import { Address } from '@xchainjs/xchain-util';
|
|
4
16
|
import { AddLiquidity, AllBalances, ExecuteSwap, LoanCloseParams, LoanOpenParams, RegisterThornameParams, TxSubmitted, UpdateThornameParams, WithdrawLiquidity } from './types';
|
|
5
17
|
import { EvmHelper } from './utils/evm-helper';
|
|
6
18
|
export type NodeUrls = Record<Network, string>;
|
|
19
|
+
export type ChainConfigs = Partial<{
|
|
20
|
+
[BTCChain]: Omit<UtxoClientParams, 'phrase' | 'network'>;
|
|
21
|
+
[BCHChain]: Omit<UtxoClientParams, 'phrase' | 'network'>;
|
|
22
|
+
[LTCChain]: Omit<UtxoClientParams, 'phrase' | 'network'>;
|
|
23
|
+
[DOGEChain]: Omit<UtxoClientParams, 'phrase' | 'network'>;
|
|
24
|
+
[ETHChain]: Omit<EVMClientParams, 'phrase' | 'network'>;
|
|
25
|
+
[AVAXChain]: Omit<EVMClientParams, 'phrase' | 'network'>;
|
|
26
|
+
[BSCChain]: Omit<EVMClientParams, 'phrase' | 'network'>;
|
|
27
|
+
[GAIAChain]: Omit<XChainClientParams, 'phrase' | 'network'>;
|
|
28
|
+
[BNBChain]: Omit<XChainClientParams, 'phrase' | 'network'>;
|
|
29
|
+
[THORChain]: Omit<XChainClientParams & ThorchainClientParams, 'phrase' | 'network'>;
|
|
30
|
+
[MAYAChain]: Omit<XChainClientParams & MayachainClientParams, 'phrase' | 'network'>;
|
|
31
|
+
}>;
|
|
7
32
|
/**
|
|
8
33
|
* Wallet Class for managing all xchain-* wallets with a mnemonic seed.
|
|
9
34
|
*/
|
|
@@ -16,9 +41,10 @@ export declare class Wallet {
|
|
|
16
41
|
*
|
|
17
42
|
* @param phrase - mnemonic phrase
|
|
18
43
|
* @param thorchainCache - an instance of the ThorchainCache (could be pointing to stagenet,testnet,mainnet)
|
|
44
|
+
* @param chainConfigs - Config by chain
|
|
19
45
|
* @returns Wallet
|
|
20
46
|
*/
|
|
21
|
-
constructor(phrase: string, thorchainQuery: ThorchainQuery);
|
|
47
|
+
constructor(phrase: string, thorchainQuery: ThorchainQuery, chainConfigs?: ChainConfigs);
|
|
22
48
|
/**
|
|
23
49
|
* Fetch balances for all wallets
|
|
24
50
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xchainjs/xchain-thorchain-amm",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.13",
|
|
4
4
|
"description": "module that exposes estimating & swappping cryptocurrency assets on thorchain",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"THORChain",
|
|
@@ -39,19 +39,19 @@
|
|
|
39
39
|
"@binance-chain/javascript-sdk": "^4.2.0",
|
|
40
40
|
"@cosmos-client/core": "0.46.1",
|
|
41
41
|
"@psf/bitcoincashjs-lib": "^4.0.3",
|
|
42
|
-
"@xchainjs/xchain-avax": "^0.3.
|
|
42
|
+
"@xchainjs/xchain-avax": "^0.3.4",
|
|
43
43
|
"@xchainjs/xchain-binance": "^5.7.4",
|
|
44
44
|
"@xchainjs/xchain-bitcoin": "^0.23.2",
|
|
45
45
|
"@xchainjs/xchain-bitcoincash": "^0.17.2",
|
|
46
|
-
"@xchainjs/xchain-client": "^0.15.
|
|
46
|
+
"@xchainjs/xchain-client": "^0.15.2",
|
|
47
47
|
"@xchainjs/xchain-cosmos": "^0.21.5",
|
|
48
|
-
"@xchainjs/xchain-bsc": "^0.3.
|
|
48
|
+
"@xchainjs/xchain-bsc": "^0.3.4",
|
|
49
49
|
"@xchainjs/xchain-crypto": "^0.3.0",
|
|
50
50
|
"@xchainjs/xchain-doge": "^0.7.3",
|
|
51
|
-
"@xchainjs/xchain-ethereum": "^0.30.
|
|
51
|
+
"@xchainjs/xchain-ethereum": "^0.30.5",
|
|
52
52
|
"@xchainjs/xchain-thornode": "^0.3.8",
|
|
53
|
-
"@xchainjs/xchain-thorchain-query": "^0.6.
|
|
54
|
-
"@xchainjs/xchain-evm": "^0.3.
|
|
53
|
+
"@xchainjs/xchain-thorchain-query": "^0.6.9",
|
|
54
|
+
"@xchainjs/xchain-evm": "^0.3.5",
|
|
55
55
|
"@xchainjs/xchain-litecoin": "^0.13.2",
|
|
56
56
|
"@xchainjs/xchain-mayachain": "^0.2.8",
|
|
57
57
|
"@xchainjs/xchain-midgard": "^0.5.2",
|
|
@@ -75,19 +75,19 @@
|
|
|
75
75
|
"@binance-chain/javascript-sdk": "^4.2.0",
|
|
76
76
|
"@cosmos-client/core": "0.46.1",
|
|
77
77
|
"@psf/bitcoincashjs-lib": "^4.0.3",
|
|
78
|
-
"@xchainjs/xchain-avax": "^0.3.
|
|
78
|
+
"@xchainjs/xchain-avax": "^0.3.4",
|
|
79
79
|
"@xchainjs/xchain-binance": "^5.7.4",
|
|
80
80
|
"@xchainjs/xchain-bitcoin": "^0.23.2",
|
|
81
81
|
"@xchainjs/xchain-bitcoincash": "^0.17.2",
|
|
82
|
-
"@xchainjs/xchain-client": "^0.15.
|
|
82
|
+
"@xchainjs/xchain-client": "^0.15.2",
|
|
83
83
|
"@xchainjs/xchain-cosmos": "^0.21.5",
|
|
84
|
-
"@xchainjs/xchain-bsc": "^0.3.
|
|
84
|
+
"@xchainjs/xchain-bsc": "^0.3.4",
|
|
85
85
|
"@xchainjs/xchain-crypto": "^0.3.0",
|
|
86
86
|
"@xchainjs/xchain-doge": "^0.7.3",
|
|
87
|
-
"@xchainjs/xchain-ethereum": "^0.30.
|
|
87
|
+
"@xchainjs/xchain-ethereum": "^0.30.5",
|
|
88
88
|
"@xchainjs/xchain-thornode": "^0.3.8",
|
|
89
|
-
"@xchainjs/xchain-thorchain-query": "^0.6.
|
|
90
|
-
"@xchainjs/xchain-evm": "^0.3.
|
|
89
|
+
"@xchainjs/xchain-thorchain-query": "^0.6.9",
|
|
90
|
+
"@xchainjs/xchain-evm": "^0.3.5",
|
|
91
91
|
"@xchainjs/xchain-litecoin": "^0.13.2",
|
|
92
92
|
"@xchainjs/xchain-mayachain": "^0.2.8",
|
|
93
93
|
"@xchainjs/xchain-midgard": "^0.5.2",
|