@xchainjs/xchain-thorchain-amm 0.7.17 → 0.8.2
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 +13 -14
- package/lib/index.js +13 -14
- package/lib/thorchain-amm.d.ts +1 -1
- package/package.json +31 -31
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.
|
|
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.
|
|
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.
|
|
318
|
-
const addressAsset = assetClient.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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,
|
|
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.
|
|
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.
|
|
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.
|
|
322
|
-
const addressAsset = assetClient.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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,
|
|
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,
|
package/lib/thorchain-amm.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export declare class ThorchainAMM {
|
|
|
27
27
|
|
|
28
28
|
* @returns The SwapEstimate
|
|
29
29
|
*/
|
|
30
|
-
estimateSwap({ fromAsset, amount,
|
|
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.
|
|
3
|
+
"version": "0.8.2",
|
|
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.
|
|
43
|
-
"@xchainjs/xchain-binance": "^5.7.
|
|
44
|
-
"@xchainjs/xchain-bitcoin": "^0.23.
|
|
45
|
-
"@xchainjs/xchain-bitcoincash": "^0.17.
|
|
46
|
-
"@xchainjs/xchain-client": "^0.15.
|
|
47
|
-
"@xchainjs/xchain-cosmos": "^0.21.
|
|
48
|
-
"@xchainjs/xchain-bsc": "^0.
|
|
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.
|
|
51
|
-
"@xchainjs/xchain-ethereum": "^0.
|
|
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.
|
|
54
|
-
"@xchainjs/xchain-evm": "^0.
|
|
55
|
-
"@xchainjs/xchain-litecoin": "^0.13.
|
|
56
|
-
"@xchainjs/xchain-mayachain": "^0.2.
|
|
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.
|
|
58
|
+
"@xchainjs/xchain-thorchain": "^0.28.13",
|
|
59
59
|
"@xchainjs/xchain-util": "^0.13.1",
|
|
60
|
-
"@xchainjs/xchain-utxo-providers": "^0.2.
|
|
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.
|
|
79
|
-
"@xchainjs/xchain-binance": "^5.7.
|
|
80
|
-
"@xchainjs/xchain-bitcoin": "^0.23.
|
|
81
|
-
"@xchainjs/xchain-bitcoincash": "^0.17.
|
|
82
|
-
"@xchainjs/xchain-client": "^0.15.
|
|
83
|
-
"@xchainjs/xchain-cosmos": "^0.21.
|
|
84
|
-
"@xchainjs/xchain-bsc": "^0.
|
|
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.
|
|
87
|
-
"@xchainjs/xchain-ethereum": "^0.
|
|
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.
|
|
90
|
-
"@xchainjs/xchain-evm": "^0.
|
|
91
|
-
"@xchainjs/xchain-litecoin": "^0.13.
|
|
92
|
-
"@xchainjs/xchain-mayachain": "^0.2.
|
|
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.
|
|
94
|
+
"@xchainjs/xchain-thorchain": "^0.28.13",
|
|
95
95
|
"@xchainjs/xchain-util": "^0.13.1",
|
|
96
|
-
"@xchainjs/xchain-utxo-providers": "^0.2.
|
|
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",
|