@xchainjs/xchain-thorchain-amm 1.0.2 → 1.0.4
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 +37 -4
- package/lib/index.js +37 -4
- package/package.json +6 -6
package/lib/index.esm.js
CHANGED
|
@@ -12390,6 +12390,34 @@ class Wallet {
|
|
|
12390
12390
|
throw Error(`getFeeRates method not supported in ${chain} chain`);
|
|
12391
12391
|
});
|
|
12392
12392
|
}
|
|
12393
|
+
/**
|
|
12394
|
+
* Estimate transfer fees
|
|
12395
|
+
* @param {UtxoTxParams | EvmTxParams} params to make the transfer estimation
|
|
12396
|
+
* @returns {Fees} Estimated fees
|
|
12397
|
+
*/
|
|
12398
|
+
estimateTransferFees(params) {
|
|
12399
|
+
return __awaiter$5(this, void 0, void 0, function* () {
|
|
12400
|
+
const client = this.getClient(params.asset.chain);
|
|
12401
|
+
if (this.isEvmClient(client)) {
|
|
12402
|
+
if (!this.isEvmTxParams(params))
|
|
12403
|
+
throw Error(`Invalid params for estimating ${params.asset.chain} transfer`);
|
|
12404
|
+
return client.getFees(params);
|
|
12405
|
+
}
|
|
12406
|
+
if (this.isUtxoClient(client)) {
|
|
12407
|
+
if (!this.isUtxoTxParams(params))
|
|
12408
|
+
throw Error(`Invalid params for estimating ${params.asset.chain} transfer`);
|
|
12409
|
+
let sender;
|
|
12410
|
+
try {
|
|
12411
|
+
sender = yield this.getAddress(params.asset.chain);
|
|
12412
|
+
}
|
|
12413
|
+
catch (_a) {
|
|
12414
|
+
/* Empty */
|
|
12415
|
+
}
|
|
12416
|
+
return client.getFees({ sender, memo: params.memo });
|
|
12417
|
+
}
|
|
12418
|
+
return client.getFees();
|
|
12419
|
+
});
|
|
12420
|
+
}
|
|
12393
12421
|
/**
|
|
12394
12422
|
* Make a transaction
|
|
12395
12423
|
* @param {TxParams} txParams txParams - The parameters to make the transfer
|
|
@@ -12437,11 +12465,11 @@ class Wallet {
|
|
|
12437
12465
|
* @returns {string} the hash of the deposit
|
|
12438
12466
|
* @throws {Error} if cannot make deposit with the asset
|
|
12439
12467
|
*/
|
|
12440
|
-
deposit({ asset, amount, memo, walletIndex, sequence, gasLimit, }) {
|
|
12468
|
+
deposit({ asset, amount, memo, walletIndex, sequence, gasLimit, chain, }) {
|
|
12441
12469
|
return __awaiter$5(this, void 0, void 0, function* () {
|
|
12442
|
-
const client = this.getClient(
|
|
12470
|
+
const client = this.getClient(chain);
|
|
12443
12471
|
if (!('deposit' in client))
|
|
12444
|
-
throw Error(`Can not deposit with ${
|
|
12472
|
+
throw Error(`Can not deposit with ${chain} client`);
|
|
12445
12473
|
return client.deposit({ asset, amount, memo, walletIndex, sequence, gasLimit });
|
|
12446
12474
|
});
|
|
12447
12475
|
}
|
|
@@ -12590,7 +12618,12 @@ class ThorchainAction {
|
|
|
12590
12618
|
}
|
|
12591
12619
|
static makeProtocolAction({ wallet, assetAmount, memo }) {
|
|
12592
12620
|
return __awaiter$6(this, void 0, void 0, function* () {
|
|
12593
|
-
const hash = yield wallet.deposit({
|
|
12621
|
+
const hash = yield wallet.deposit({
|
|
12622
|
+
chain: THORChain,
|
|
12623
|
+
asset: assetAmount.asset,
|
|
12624
|
+
amount: assetAmount.baseAmount,
|
|
12625
|
+
memo,
|
|
12626
|
+
});
|
|
12594
12627
|
return {
|
|
12595
12628
|
hash,
|
|
12596
12629
|
url: yield wallet.getExplorerTxUrl(assetAmount.asset.chain, hash),
|
package/lib/index.js
CHANGED
|
@@ -12394,6 +12394,34 @@ class Wallet {
|
|
|
12394
12394
|
throw Error(`getFeeRates method not supported in ${chain} chain`);
|
|
12395
12395
|
});
|
|
12396
12396
|
}
|
|
12397
|
+
/**
|
|
12398
|
+
* Estimate transfer fees
|
|
12399
|
+
* @param {UtxoTxParams | EvmTxParams} params to make the transfer estimation
|
|
12400
|
+
* @returns {Fees} Estimated fees
|
|
12401
|
+
*/
|
|
12402
|
+
estimateTransferFees(params) {
|
|
12403
|
+
return __awaiter$5(this, void 0, void 0, function* () {
|
|
12404
|
+
const client = this.getClient(params.asset.chain);
|
|
12405
|
+
if (this.isEvmClient(client)) {
|
|
12406
|
+
if (!this.isEvmTxParams(params))
|
|
12407
|
+
throw Error(`Invalid params for estimating ${params.asset.chain} transfer`);
|
|
12408
|
+
return client.getFees(params);
|
|
12409
|
+
}
|
|
12410
|
+
if (this.isUtxoClient(client)) {
|
|
12411
|
+
if (!this.isUtxoTxParams(params))
|
|
12412
|
+
throw Error(`Invalid params for estimating ${params.asset.chain} transfer`);
|
|
12413
|
+
let sender;
|
|
12414
|
+
try {
|
|
12415
|
+
sender = yield this.getAddress(params.asset.chain);
|
|
12416
|
+
}
|
|
12417
|
+
catch (_a) {
|
|
12418
|
+
/* Empty */
|
|
12419
|
+
}
|
|
12420
|
+
return client.getFees({ sender, memo: params.memo });
|
|
12421
|
+
}
|
|
12422
|
+
return client.getFees();
|
|
12423
|
+
});
|
|
12424
|
+
}
|
|
12397
12425
|
/**
|
|
12398
12426
|
* Make a transaction
|
|
12399
12427
|
* @param {TxParams} txParams txParams - The parameters to make the transfer
|
|
@@ -12441,11 +12469,11 @@ class Wallet {
|
|
|
12441
12469
|
* @returns {string} the hash of the deposit
|
|
12442
12470
|
* @throws {Error} if cannot make deposit with the asset
|
|
12443
12471
|
*/
|
|
12444
|
-
deposit({ asset, amount, memo, walletIndex, sequence, gasLimit, }) {
|
|
12472
|
+
deposit({ asset, amount, memo, walletIndex, sequence, gasLimit, chain, }) {
|
|
12445
12473
|
return __awaiter$5(this, void 0, void 0, function* () {
|
|
12446
|
-
const client = this.getClient(
|
|
12474
|
+
const client = this.getClient(chain);
|
|
12447
12475
|
if (!('deposit' in client))
|
|
12448
|
-
throw Error(`Can not deposit with ${
|
|
12476
|
+
throw Error(`Can not deposit with ${chain} client`);
|
|
12449
12477
|
return client.deposit({ asset, amount, memo, walletIndex, sequence, gasLimit });
|
|
12450
12478
|
});
|
|
12451
12479
|
}
|
|
@@ -12594,7 +12622,12 @@ class ThorchainAction {
|
|
|
12594
12622
|
}
|
|
12595
12623
|
static makeProtocolAction({ wallet, assetAmount, memo }) {
|
|
12596
12624
|
return __awaiter$6(this, void 0, void 0, function* () {
|
|
12597
|
-
const hash = yield wallet.deposit({
|
|
12625
|
+
const hash = yield wallet.deposit({
|
|
12626
|
+
chain: xchainThorchain.THORChain,
|
|
12627
|
+
asset: assetAmount.asset,
|
|
12628
|
+
amount: assetAmount.baseAmount,
|
|
12629
|
+
memo,
|
|
12630
|
+
});
|
|
12598
12631
|
return {
|
|
12599
12632
|
hash,
|
|
12600
12633
|
url: yield wallet.getExplorerTxUrl(assetAmount.asset.chain, hash),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xchainjs/xchain-thorchain-amm",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "module that exposes estimating & swappping cryptocurrency assets on thorchain",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"THORChain",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@xchainjs/xchain-avax": "0.4.6",
|
|
40
|
-
"@xchainjs/xchain-binance": "5.7.
|
|
40
|
+
"@xchainjs/xchain-binance": "5.7.11",
|
|
41
41
|
"@xchainjs/xchain-bitcoin": "0.23.13",
|
|
42
42
|
"@xchainjs/xchain-bitcoincash": "0.17.10",
|
|
43
43
|
"@xchainjs/xchain-bsc": "0.4.7",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"@xchainjs/xchain-ethereum": "0.31.6",
|
|
47
47
|
"@xchainjs/xchain-litecoin": "0.13.11",
|
|
48
48
|
"@xchainjs/xchain-thorchain": "1.0.4",
|
|
49
|
-
"@xchainjs/xchain-thorchain-query": "0.7.
|
|
49
|
+
"@xchainjs/xchain-thorchain-query": "0.7.6",
|
|
50
50
|
"@xchainjs/xchain-util": "^0.13.3",
|
|
51
|
-
"@xchainjs/xchain-wallet": "0.1.
|
|
51
|
+
"@xchainjs/xchain-wallet": "0.1.8",
|
|
52
52
|
"@xchainjs/xchain-mayachain": "1.0.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@psf/bitcoincashjs-lib": "^4.0.3",
|
|
58
58
|
"@xchainjs/xchain-client": "^0.16.2",
|
|
59
59
|
"@xchainjs/xchain-crypto": "^0.3.1",
|
|
60
|
-
"@xchainjs/xchain-thornode": "^0.3.
|
|
60
|
+
"@xchainjs/xchain-thornode": "^0.3.11",
|
|
61
61
|
"@xchainjs/xchain-evm": "^0.4.5",
|
|
62
62
|
"@xchainjs/xchain-midgard": "^0.5.2",
|
|
63
63
|
"@xchainjs/xchain-utxo-providers": "^0.2.12",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"@psf/bitcoincashjs-lib": "^4.0.3",
|
|
81
81
|
"@xchainjs/xchain-client": "^0.16.2",
|
|
82
82
|
"@xchainjs/xchain-crypto": "^0.3.1",
|
|
83
|
-
"@xchainjs/xchain-thornode": "^0.3.
|
|
83
|
+
"@xchainjs/xchain-thornode": "^0.3.11",
|
|
84
84
|
"@xchainjs/xchain-evm": "^0.4.5",
|
|
85
85
|
"@xchainjs/xchain-midgard": "^0.5.2",
|
|
86
86
|
"@xchainjs/xchain-util": "^0.13.3",
|