@xchainjs/xchain-thorchain-amm 0.7.14 → 0.8.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 CHANGED
@@ -67,7 +67,7 @@ class EvmHelper {
67
67
  if (!(inboundAsgard === null || inboundAsgard === void 0 ? void 0 : inboundAsgard.address)) {
68
68
  throw new Error('Vault address is not defined');
69
69
  }
70
- const address = this.client.getAddress(params.walletIndex);
70
+ const address = yield this.client.getAddressAsync(params.walletIndex);
71
71
  const gasPrice = yield this.evmClient.estimateGasPrices(Protocol.THORCHAIN);
72
72
  if (eqAsset(params.asset, this.evmClient.config.gasAsset)) {
73
73
  // simple transfer
@@ -180,7 +180,7 @@ class Wallet {
180
180
  return __awaiter(this, void 0, void 0, function* () {
181
181
  const allBalances = [];
182
182
  for (const [chain, client] of Object.entries(this.clients)) {
183
- const address = client.getAddress(0);
183
+ const address = yield client.getAddressAsync(0);
184
184
  try {
185
185
  const balances = yield client.getBalance(address);
186
186
  allBalances.push({ chain, address, balances });
@@ -314,8 +314,8 @@ class Wallet {
314
314
  const inboundAsgard = (yield this.thorchainQuery.thorchainCache.getInboundDetails())[params.asset.asset.chain]
315
315
  .address;
316
316
  const thorchainClient = this.clients[params.rune.asset.chain];
317
- const addressRune = thorchainClient.getAddress();
318
- const addressAsset = assetClient.getAddress();
317
+ const addressRune = yield thorchainClient.getAddressAsync();
318
+ const addressAsset = yield assetClient.getAddressAsync();
319
319
  // const waitTimeSeconds = params.waitTimeSeconds
320
320
  let constructedMemo = '';
321
321
  const txSubmitted = [];
@@ -454,7 +454,7 @@ class Wallet {
454
454
  }
455
455
  catch (err) {
456
456
  const hash = JSON.stringify(err);
457
- return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()) };
457
+ return { hash, url: yield assetClient.getExplorerAddressUrl(yield assetClient.getAddressAsync()) };
458
458
  }
459
459
  }
460
460
  });
@@ -488,7 +488,7 @@ class Wallet {
488
488
  }
489
489
  catch (err) {
490
490
  const hash = JSON.stringify(err);
491
- return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()) };
491
+ return { hash, url: assetClient.getExplorerAddressUrl(yield assetClient.getAddressAsync()) };
492
492
  }
493
493
  }
494
494
  });
@@ -522,7 +522,7 @@ class Wallet {
522
522
  }
523
523
  catch (err) {
524
524
  const hash = JSON.stringify(err);
525
- return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()) };
525
+ return { hash, url: assetClient.getExplorerAddressUrl(yield assetClient.getAddressAsync()) };
526
526
  }
527
527
  }
528
528
  });
@@ -546,7 +546,7 @@ class Wallet {
546
546
  if (!chainClient || !thorClient) {
547
547
  throw Error('Can not find a wallet client');
548
548
  }
549
- const thornameEstimation = yield this.thorchainQuery.estimateThorname(Object.assign(Object.assign({}, params), { chain: params.chain || BTCChain, chainAddress: params.chainAddress || chainClient.getAddress(), owner: params.owner || thorClient.getAddress() }));
549
+ const thornameEstimation = yield this.thorchainQuery.estimateThorname(Object.assign(Object.assign({}, params), { chain: params.chain || BTCChain, chainAddress: params.chainAddress || (yield chainClient.getAddressAsync()), owner: params.owner || (yield thorClient.getAddressAsync()) }));
550
550
  const castedThorClient = thorClient;
551
551
  const result = yield castedThorClient.deposit({
552
552
  asset: thornameEstimation.value.asset,
@@ -575,10 +575,10 @@ class Wallet {
575
575
  throw Error('Can not find a wallet client');
576
576
  }
577
577
  const thornameDetail = yield this.thorchainQuery.getThornameDetails(params.thorname);
578
- if ((thornameDetail === null || thornameDetail === void 0 ? void 0 : thornameDetail.owner) !== thorClient.getAddress()) {
578
+ if ((thornameDetail === null || thornameDetail === void 0 ? void 0 : thornameDetail.owner) !== (yield thorClient.getAddressAsync())) {
579
579
  throw Error('You cannot update a domain that is not yours');
580
580
  }
581
- const thornameEstimation = yield this.thorchainQuery.estimateThorname(Object.assign(Object.assign({}, params), { chain: params.chain || BTCChain, isUpdate: true, preferredAsset: params.preferredAsset || assetFromString(thornameDetail.preferredAsset), chainAddress: params.chainAddress || chainClient.getAddress() }));
581
+ const thornameEstimation = yield this.thorchainQuery.estimateThorname(Object.assign(Object.assign({}, params), { chain: params.chain || BTCChain, isUpdate: true, preferredAsset: params.preferredAsset || assetFromString(thornameDetail.preferredAsset), chainAddress: params.chainAddress || (yield chainClient.getAddressAsync()) }));
582
582
  const castedThorClient = thorClient;
583
583
  const result = yield castedThorClient.deposit({
584
584
  asset: thornameEstimation.value.asset,
@@ -625,7 +625,7 @@ class Wallet {
625
625
  }
626
626
  catch (err) {
627
627
  const hash = JSON.stringify(err);
628
- return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()) };
628
+ return { hash, url: assetClient.getExplorerAddressUrl(yield assetClient.getAddressAsync()) };
629
629
  }
630
630
  }
631
631
  });
@@ -667,7 +667,7 @@ class Wallet {
667
667
  }
668
668
  catch (err) {
669
669
  const hash = JSON.stringify(err);
670
- return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()) };
670
+ return { hash, url: assetClient.getExplorerAddressUrl(yield assetClient.getAddressAsync()) };
671
671
  }
672
672
  }
673
673
  });
@@ -742,7 +742,7 @@ class ThorchainAMM {
742
742
 
743
743
  * @returns The SwapEstimate
744
744
  */
745
- estimateSwap({ fromAsset, amount, fromAddress, destinationAsset, destinationAddress, affiliateAddress = '', interfaceID = `555`, affiliateBps = 0, toleranceBps, wallet, walletIndex, }) {
745
+ estimateSwap({ fromAsset, amount, destinationAsset, destinationAddress, affiliateAddress = '', interfaceID = `555`, affiliateBps = 0, toleranceBps, wallet, walletIndex, }) {
746
746
  return __awaiter(this, void 0, void 0, function* () {
747
747
  let errors = [];
748
748
  if (wallet) {
@@ -759,7 +759,6 @@ class ThorchainAMM {
759
759
  const estimate = yield this.thorchainQuery.quoteSwap({
760
760
  fromAsset,
761
761
  amount,
762
- fromAddress,
763
762
  destinationAsset,
764
763
  destinationAddress,
765
764
  affiliateAddress,
package/lib/index.js CHANGED
@@ -71,7 +71,7 @@ class EvmHelper {
71
71
  if (!(inboundAsgard === null || inboundAsgard === void 0 ? void 0 : inboundAsgard.address)) {
72
72
  throw new Error('Vault address is not defined');
73
73
  }
74
- const address = this.client.getAddress(params.walletIndex);
74
+ const address = yield this.client.getAddressAsync(params.walletIndex);
75
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
@@ -184,7 +184,7 @@ class Wallet {
184
184
  return __awaiter(this, void 0, void 0, function* () {
185
185
  const allBalances = [];
186
186
  for (const [chain, client] of Object.entries(this.clients)) {
187
- const address = client.getAddress(0);
187
+ const address = yield client.getAddressAsync(0);
188
188
  try {
189
189
  const balances = yield client.getBalance(address);
190
190
  allBalances.push({ chain, address, balances });
@@ -318,8 +318,8 @@ class Wallet {
318
318
  const inboundAsgard = (yield this.thorchainQuery.thorchainCache.getInboundDetails())[params.asset.asset.chain]
319
319
  .address;
320
320
  const thorchainClient = this.clients[params.rune.asset.chain];
321
- const addressRune = thorchainClient.getAddress();
322
- const addressAsset = assetClient.getAddress();
321
+ const addressRune = yield thorchainClient.getAddressAsync();
322
+ const addressAsset = yield assetClient.getAddressAsync();
323
323
  // const waitTimeSeconds = params.waitTimeSeconds
324
324
  let constructedMemo = '';
325
325
  const txSubmitted = [];
@@ -458,7 +458,7 @@ class Wallet {
458
458
  }
459
459
  catch (err) {
460
460
  const hash = JSON.stringify(err);
461
- return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()) };
461
+ return { hash, url: yield assetClient.getExplorerAddressUrl(yield assetClient.getAddressAsync()) };
462
462
  }
463
463
  }
464
464
  });
@@ -492,7 +492,7 @@ class Wallet {
492
492
  }
493
493
  catch (err) {
494
494
  const hash = JSON.stringify(err);
495
- return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()) };
495
+ return { hash, url: assetClient.getExplorerAddressUrl(yield assetClient.getAddressAsync()) };
496
496
  }
497
497
  }
498
498
  });
@@ -526,7 +526,7 @@ class Wallet {
526
526
  }
527
527
  catch (err) {
528
528
  const hash = JSON.stringify(err);
529
- return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()) };
529
+ return { hash, url: assetClient.getExplorerAddressUrl(yield assetClient.getAddressAsync()) };
530
530
  }
531
531
  }
532
532
  });
@@ -550,7 +550,7 @@ class Wallet {
550
550
  if (!chainClient || !thorClient) {
551
551
  throw Error('Can not find a wallet client');
552
552
  }
553
- const thornameEstimation = yield this.thorchainQuery.estimateThorname(Object.assign(Object.assign({}, params), { chain: params.chain || xchainBitcoin.BTCChain, chainAddress: params.chainAddress || chainClient.getAddress(), owner: params.owner || thorClient.getAddress() }));
553
+ const thornameEstimation = yield this.thorchainQuery.estimateThorname(Object.assign(Object.assign({}, params), { chain: params.chain || xchainBitcoin.BTCChain, chainAddress: params.chainAddress || (yield chainClient.getAddressAsync()), owner: params.owner || (yield thorClient.getAddressAsync()) }));
554
554
  const castedThorClient = thorClient;
555
555
  const result = yield castedThorClient.deposit({
556
556
  asset: thornameEstimation.value.asset,
@@ -579,10 +579,10 @@ class Wallet {
579
579
  throw Error('Can not find a wallet client');
580
580
  }
581
581
  const thornameDetail = yield this.thorchainQuery.getThornameDetails(params.thorname);
582
- if ((thornameDetail === null || thornameDetail === void 0 ? void 0 : thornameDetail.owner) !== thorClient.getAddress()) {
582
+ if ((thornameDetail === null || thornameDetail === void 0 ? void 0 : thornameDetail.owner) !== (yield thorClient.getAddressAsync())) {
583
583
  throw Error('You cannot update a domain that is not yours');
584
584
  }
585
- const thornameEstimation = yield this.thorchainQuery.estimateThorname(Object.assign(Object.assign({}, params), { chain: params.chain || xchainBitcoin.BTCChain, isUpdate: true, preferredAsset: params.preferredAsset || xchainUtil.assetFromString(thornameDetail.preferredAsset), chainAddress: params.chainAddress || chainClient.getAddress() }));
585
+ const thornameEstimation = yield this.thorchainQuery.estimateThorname(Object.assign(Object.assign({}, params), { chain: params.chain || xchainBitcoin.BTCChain, isUpdate: true, preferredAsset: params.preferredAsset || xchainUtil.assetFromString(thornameDetail.preferredAsset), chainAddress: params.chainAddress || (yield chainClient.getAddressAsync()) }));
586
586
  const castedThorClient = thorClient;
587
587
  const result = yield castedThorClient.deposit({
588
588
  asset: thornameEstimation.value.asset,
@@ -629,7 +629,7 @@ class Wallet {
629
629
  }
630
630
  catch (err) {
631
631
  const hash = JSON.stringify(err);
632
- return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()) };
632
+ return { hash, url: assetClient.getExplorerAddressUrl(yield assetClient.getAddressAsync()) };
633
633
  }
634
634
  }
635
635
  });
@@ -671,7 +671,7 @@ class Wallet {
671
671
  }
672
672
  catch (err) {
673
673
  const hash = JSON.stringify(err);
674
- return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()) };
674
+ return { hash, url: assetClient.getExplorerAddressUrl(yield assetClient.getAddressAsync()) };
675
675
  }
676
676
  }
677
677
  });
@@ -746,7 +746,7 @@ class ThorchainAMM {
746
746
 
747
747
  * @returns The SwapEstimate
748
748
  */
749
- estimateSwap({ fromAsset, amount, fromAddress, destinationAsset, destinationAddress, affiliateAddress = '', interfaceID = `555`, affiliateBps = 0, toleranceBps, wallet, walletIndex, }) {
749
+ estimateSwap({ fromAsset, amount, destinationAsset, destinationAddress, affiliateAddress = '', interfaceID = `555`, affiliateBps = 0, toleranceBps, wallet, walletIndex, }) {
750
750
  return __awaiter(this, void 0, void 0, function* () {
751
751
  let errors = [];
752
752
  if (wallet) {
@@ -763,7 +763,6 @@ class ThorchainAMM {
763
763
  const estimate = yield this.thorchainQuery.quoteSwap({
764
764
  fromAsset,
765
765
  amount,
766
- fromAddress,
767
766
  destinationAsset,
768
767
  destinationAddress,
769
768
  affiliateAddress,
@@ -27,7 +27,7 @@ export declare class ThorchainAMM {
27
27
 
28
28
  * @returns The SwapEstimate
29
29
  */
30
- estimateSwap({ fromAsset, amount, fromAddress, destinationAsset, destinationAddress, affiliateAddress, interfaceID, affiliateBps, toleranceBps, wallet, walletIndex, }: AmmEstimateSwapParams): Promise<TxDetails>;
30
+ estimateSwap({ fromAsset, amount, destinationAsset, destinationAddress, affiliateAddress, interfaceID, affiliateBps, toleranceBps, wallet, walletIndex, }: AmmEstimateSwapParams): Promise<TxDetails>;
31
31
  /**
32
32
  * Conducts a swap with the given inputs. Should be called after estimateSwap() to ensure the swap is valid
33
33
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-thorchain-amm",
3
- "version": "0.7.14",
3
+ "version": "0.8.1",
4
4
  "description": "module that exposes estimating & swappping cryptocurrency assets on thorchain",
5
5
  "keywords": [
6
6
  "THORChain",
@@ -39,25 +39,25 @@
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.4",
43
- "@xchainjs/xchain-binance": "^5.7.4",
44
- "@xchainjs/xchain-bitcoin": "^0.23.2",
45
- "@xchainjs/xchain-bitcoincash": "^0.17.2",
46
- "@xchainjs/xchain-client": "^0.15.2",
47
- "@xchainjs/xchain-cosmos": "^0.21.6",
48
- "@xchainjs/xchain-bsc": "^0.3.4",
42
+ "@xchainjs/xchain-avax": "^0.4.1",
43
+ "@xchainjs/xchain-binance": "^5.7.5",
44
+ "@xchainjs/xchain-bitcoin": "^0.23.4",
45
+ "@xchainjs/xchain-bitcoincash": "^0.17.4",
46
+ "@xchainjs/xchain-client": "^0.15.3",
47
+ "@xchainjs/xchain-cosmos": "^0.21.7",
48
+ "@xchainjs/xchain-bsc": "^0.4.1",
49
49
  "@xchainjs/xchain-crypto": "^0.3.0",
50
- "@xchainjs/xchain-doge": "^0.7.3",
51
- "@xchainjs/xchain-ethereum": "^0.30.5",
50
+ "@xchainjs/xchain-doge": "^0.7.5",
51
+ "@xchainjs/xchain-ethereum": "^0.31.1",
52
52
  "@xchainjs/xchain-thornode": "^0.3.8",
53
- "@xchainjs/xchain-thorchain-query": "^0.6.10",
54
- "@xchainjs/xchain-evm": "^0.3.5",
55
- "@xchainjs/xchain-litecoin": "^0.13.2",
56
- "@xchainjs/xchain-mayachain": "^0.2.9",
53
+ "@xchainjs/xchain-thorchain-query": "^0.6.11",
54
+ "@xchainjs/xchain-evm": "^0.4.1",
55
+ "@xchainjs/xchain-litecoin": "^0.13.4",
56
+ "@xchainjs/xchain-mayachain": "^0.2.10",
57
57
  "@xchainjs/xchain-midgard": "^0.5.2",
58
- "@xchainjs/xchain-thorchain": "^0.28.10",
58
+ "@xchainjs/xchain-thorchain": "^0.28.12",
59
59
  "@xchainjs/xchain-util": "^0.13.1",
60
- "@xchainjs/xchain-utxo-providers": "^0.2.5",
60
+ "@xchainjs/xchain-utxo-providers": "^0.2.7",
61
61
  "axios": "^1.3.6",
62
62
  "axios-retry": "^3.2.5",
63
63
  "bchaddrjs": "^0.5.2",
@@ -75,25 +75,25 @@
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.4",
79
- "@xchainjs/xchain-binance": "^5.7.4",
80
- "@xchainjs/xchain-bitcoin": "^0.23.2",
81
- "@xchainjs/xchain-bitcoincash": "^0.17.2",
82
- "@xchainjs/xchain-client": "^0.15.2",
83
- "@xchainjs/xchain-cosmos": "^0.21.6",
84
- "@xchainjs/xchain-bsc": "^0.3.4",
78
+ "@xchainjs/xchain-avax": "^0.4.1",
79
+ "@xchainjs/xchain-binance": "^5.7.5",
80
+ "@xchainjs/xchain-bitcoin": "^0.23.4",
81
+ "@xchainjs/xchain-bitcoincash": "^0.17.4",
82
+ "@xchainjs/xchain-client": "^0.15.3",
83
+ "@xchainjs/xchain-cosmos": "^0.21.7",
84
+ "@xchainjs/xchain-bsc": "^0.4.1",
85
85
  "@xchainjs/xchain-crypto": "^0.3.0",
86
- "@xchainjs/xchain-doge": "^0.7.3",
87
- "@xchainjs/xchain-ethereum": "^0.30.5",
86
+ "@xchainjs/xchain-doge": "^0.7.5",
87
+ "@xchainjs/xchain-ethereum": "^0.31.1",
88
88
  "@xchainjs/xchain-thornode": "^0.3.8",
89
- "@xchainjs/xchain-thorchain-query": "^0.6.10",
90
- "@xchainjs/xchain-evm": "^0.3.5",
91
- "@xchainjs/xchain-litecoin": "^0.13.2",
92
- "@xchainjs/xchain-mayachain": "^0.2.9",
89
+ "@xchainjs/xchain-thorchain-query": "^0.6.11",
90
+ "@xchainjs/xchain-evm": "^0.4.1",
91
+ "@xchainjs/xchain-litecoin": "^0.13.4",
92
+ "@xchainjs/xchain-mayachain": "^0.2.10",
93
93
  "@xchainjs/xchain-midgard": "^0.5.2",
94
- "@xchainjs/xchain-thorchain": "^0.28.10",
94
+ "@xchainjs/xchain-thorchain": "^0.28.12",
95
95
  "@xchainjs/xchain-util": "^0.13.1",
96
- "@xchainjs/xchain-utxo-providers": "^0.2.5",
96
+ "@xchainjs/xchain-utxo-providers": "^0.2.7",
97
97
  "axios": "^1.3.6",
98
98
  "axios-retry": "^3.2.5",
99
99
  "bchaddrjs": "^0.5.2",
@@ -109,4 +109,4 @@
109
109
  "publishConfig": {
110
110
  "access": "public"
111
111
  }
112
- }
112
+ }