@xchainjs/xchain-thorchain-amm 0.3.22 → 0.3.24

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
@@ -339,6 +339,9 @@ class Wallet {
339
339
  errors.push(`affiliateAddress ${affiliateAddress} is not a valid THOR address`);
340
340
  }
341
341
  }
342
+ // if input == synth return errors.
343
+ if (swap.input.asset.synth)
344
+ return errors;
342
345
  if (swap.input.asset.chain === ETHChain) {
343
346
  if (eqAsset(swap.input.asset, AssetETH) !== true) {
344
347
  const isApprovedResult = yield this.ethHelper.isTCRouterApprovedToSpend(swap.input.asset, swap.input.baseAmount, swap.walletIndex);
@@ -959,6 +962,36 @@ class ThorchainAMM {
959
962
  });
960
963
  });
961
964
  }
965
+ /**
966
+ *
967
+ * @param addAssetAmount
968
+ * @returns
969
+ */
970
+ estimateAddSaver(addAssetAmount) {
971
+ return __awaiter(this, void 0, void 0, function* () {
972
+ return yield this.thorchainQuery.estimateAddSaver(addAssetAmount);
973
+ });
974
+ }
975
+ /**
976
+ *
977
+ * @param withdrawParams
978
+ * @returns
979
+ */
980
+ estimateWithdrawSaver(withdrawParams) {
981
+ return __awaiter(this, void 0, void 0, function* () {
982
+ return yield this.thorchainQuery.estimateWithdrawSaver(withdrawParams);
983
+ });
984
+ }
985
+ /**
986
+ *
987
+ * @param getsaver
988
+ * @returns
989
+ */
990
+ getSaverPosition(getsaver) {
991
+ return __awaiter(this, void 0, void 0, function* () {
992
+ return yield this.thorchainQuery.getSaverPosition(getsaver);
993
+ });
994
+ }
962
995
  /**
963
996
  *
964
997
  * @param wallet - wallet needed to execute tx
@@ -970,7 +1003,7 @@ class ThorchainAMM {
970
1003
  const addEstimate = yield this.thorchainQuery.estimateAddSaver(addAssetAmount);
971
1004
  if (!addEstimate.canAddSaver)
972
1005
  throw Error(`Cannot add to savers`);
973
- return yield wallet.addSavers(addEstimate.assetAmount, addEstimate.memo, addEstimate.toAddress, addEstimate.estimatedWaitTime);
1006
+ return yield wallet.addSavers(addAssetAmount, addEstimate.memo, addEstimate.toAddress, addEstimate.estimatedWaitTime);
974
1007
  });
975
1008
  }
976
1009
  /**
@@ -982,6 +1015,8 @@ class ThorchainAMM {
982
1015
  withdrawSaver(wallet, withdrawParams) {
983
1016
  return __awaiter(this, void 0, void 0, function* () {
984
1017
  const withdrawEstimate = yield this.thorchainQuery.estimateWithdrawSaver(withdrawParams);
1018
+ if (withdrawEstimate.errors.length > 0)
1019
+ throw Error(`${withdrawEstimate.errors}`);
985
1020
  return yield wallet.withdrawSavers(withdrawEstimate.dustAmount, withdrawEstimate.memo, withdrawEstimate.toAddress, withdrawEstimate.estimatedWaitTime);
986
1021
  });
987
1022
  }
package/lib/index.js CHANGED
@@ -343,6 +343,9 @@ class Wallet {
343
343
  errors.push(`affiliateAddress ${affiliateAddress} is not a valid THOR address`);
344
344
  }
345
345
  }
346
+ // if input == synth return errors.
347
+ if (swap.input.asset.synth)
348
+ return errors;
346
349
  if (swap.input.asset.chain === xchainEthereum.ETHChain) {
347
350
  if (xchainUtil.eqAsset(swap.input.asset, xchainEthereum.AssetETH) !== true) {
348
351
  const isApprovedResult = yield this.ethHelper.isTCRouterApprovedToSpend(swap.input.asset, swap.input.baseAmount, swap.walletIndex);
@@ -963,6 +966,36 @@ class ThorchainAMM {
963
966
  });
964
967
  });
965
968
  }
969
+ /**
970
+ *
971
+ * @param addAssetAmount
972
+ * @returns
973
+ */
974
+ estimateAddSaver(addAssetAmount) {
975
+ return __awaiter(this, void 0, void 0, function* () {
976
+ return yield this.thorchainQuery.estimateAddSaver(addAssetAmount);
977
+ });
978
+ }
979
+ /**
980
+ *
981
+ * @param withdrawParams
982
+ * @returns
983
+ */
984
+ estimateWithdrawSaver(withdrawParams) {
985
+ return __awaiter(this, void 0, void 0, function* () {
986
+ return yield this.thorchainQuery.estimateWithdrawSaver(withdrawParams);
987
+ });
988
+ }
989
+ /**
990
+ *
991
+ * @param getsaver
992
+ * @returns
993
+ */
994
+ getSaverPosition(getsaver) {
995
+ return __awaiter(this, void 0, void 0, function* () {
996
+ return yield this.thorchainQuery.getSaverPosition(getsaver);
997
+ });
998
+ }
966
999
  /**
967
1000
  *
968
1001
  * @param wallet - wallet needed to execute tx
@@ -974,7 +1007,7 @@ class ThorchainAMM {
974
1007
  const addEstimate = yield this.thorchainQuery.estimateAddSaver(addAssetAmount);
975
1008
  if (!addEstimate.canAddSaver)
976
1009
  throw Error(`Cannot add to savers`);
977
- return yield wallet.addSavers(addEstimate.assetAmount, addEstimate.memo, addEstimate.toAddress, addEstimate.estimatedWaitTime);
1010
+ return yield wallet.addSavers(addAssetAmount, addEstimate.memo, addEstimate.toAddress, addEstimate.estimatedWaitTime);
978
1011
  });
979
1012
  }
980
1013
  /**
@@ -986,6 +1019,8 @@ class ThorchainAMM {
986
1019
  withdrawSaver(wallet, withdrawParams) {
987
1020
  return __awaiter(this, void 0, void 0, function* () {
988
1021
  const withdrawEstimate = yield this.thorchainQuery.estimateWithdrawSaver(withdrawParams);
1022
+ if (withdrawEstimate.errors.length > 0)
1023
+ throw Error(`${withdrawEstimate.errors}`);
989
1024
  return yield wallet.withdrawSavers(withdrawEstimate.dustAmount, withdrawEstimate.memo, withdrawEstimate.toAddress, withdrawEstimate.estimatedWaitTime);
990
1025
  });
991
1026
  }
@@ -1,4 +1,4 @@
1
- import { AddliquidityPosition, CryptoAmount, EstimateAddLP, EstimateSwapParams, EstimateWithdrawLP, SaversWithdraw, ThorchainQuery, TxDetails, WithdrawLiquidityPosition } from '@xchainjs/xchain-thorchain-query';
1
+ import { AddliquidityPosition, CryptoAmount, EstimateAddLP, EstimateAddSaver, EstimateSwapParams, EstimateWithdrawLP, EstimateWithdrawSaver, SaversPosition, SaversWithdraw, ThorchainQuery, TxDetails, WithdrawLiquidityPosition, getSaver } from '@xchainjs/xchain-thorchain-query';
2
2
  import { TxSubmitted } from './types';
3
3
  import { Wallet } from './wallet';
4
4
  export declare type AmmEstimateSwapParams = EstimateSwapParams & {
@@ -62,6 +62,24 @@ export declare class ThorchainAMM {
62
62
  * @return
63
63
  */
64
64
  withdrawLiquidityPosition(wallet: Wallet, params: WithdrawLiquidityPosition): Promise<TxSubmitted[]>;
65
+ /**
66
+ *
67
+ * @param addAssetAmount
68
+ * @returns
69
+ */
70
+ estimateAddSaver(addAssetAmount: CryptoAmount): Promise<EstimateAddSaver>;
71
+ /**
72
+ *
73
+ * @param withdrawParams
74
+ * @returns
75
+ */
76
+ estimateWithdrawSaver(withdrawParams: SaversWithdraw): Promise<EstimateWithdrawSaver>;
77
+ /**
78
+ *
79
+ * @param getsaver
80
+ * @returns
81
+ */
82
+ getSaverPosition(getsaver: getSaver): Promise<SaversPosition>;
65
83
  /**
66
84
  *
67
85
  * @param wallet - wallet needed to execute tx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-thorchain-amm",
3
- "version": "0.3.22",
3
+ "version": "0.3.24",
4
4
  "description": "module that exposes estimating & swappping cryptocurrency assets on thorchain",
5
5
  "keywords": [
6
6
  "THORChain",
@@ -39,24 +39,24 @@
39
39
  "@binance-chain/javascript-sdk": "^4.2.0",
40
40
  "@cosmos-client/core": "0.46.1",
41
41
  "@psf/bitcoincashjs-lib": "^4.0.2",
42
- "@xchainjs/xchain-avax": "^0.1.6",
42
+ "@xchainjs/xchain-avax": "^0.1.8",
43
43
  "@xchainjs/xchain-bsc": "^0.1.3",
44
44
  "@xchainjs/xchain-binance": "^5.6.8",
45
- "@xchainjs/xchain-bitcoin": "^0.21.3",
46
- "@xchainjs/xchain-bitcoincash": "^0.15.10",
45
+ "@xchainjs/xchain-bitcoin": "^0.21.4",
46
+ "@xchainjs/xchain-bitcoincash": "^0.15.11",
47
47
  "@xchainjs/xchain-client": "^0.13.7",
48
48
  "@xchainjs/xchain-cosmos": "^0.20.9",
49
49
  "@xchainjs/xchain-crypto": "^0.2.6",
50
- "@xchainjs/xchain-doge": "^0.5.12",
50
+ "@xchainjs/xchain-doge": "^0.5.13",
51
51
  "@xchainjs/xchain-ethereum": "^0.27.8",
52
52
  "@xchainjs/xchain-evm": "^0.1.5",
53
- "@xchainjs/xchain-litecoin": "^0.11.3",
53
+ "@xchainjs/xchain-litecoin": "^0.11.4",
54
54
  "@xchainjs/xchain-midgard": "0.4.3",
55
55
  "@xchainjs/xchain-thorchain": "^0.27.9",
56
- "@xchainjs/xchain-thorchain-query": "^0.2.2",
56
+ "@xchainjs/xchain-thorchain-query": "^0.2.5",
57
57
  "@xchainjs/xchain-thornode": "^0.2.2",
58
58
  "@xchainjs/xchain-util": "^0.12.0",
59
- "@xchainjs/xchain-utxo-providers": "^0.1.1",
59
+ "@xchainjs/xchain-utxo-providers": "^0.1.2",
60
60
  "axios": "^0.25.0",
61
61
  "axios-retry": "^3.2.5",
62
62
  "bchaddrjs": "^0.5.2",
@@ -74,24 +74,24 @@
74
74
  "@binance-chain/javascript-sdk": "^4.2.0",
75
75
  "@cosmos-client/core": "0.46.1",
76
76
  "@psf/bitcoincashjs-lib": "^4.0.2",
77
- "@xchainjs/xchain-avax": "^0.1.5",
77
+ "@xchainjs/xchain-avax": "^0.1.8",
78
78
  "@xchainjs/xchain-bsc": "^0.1.2",
79
79
  "@xchainjs/xchain-binance": "^5.6.7",
80
- "@xchainjs/xchain-bitcoin": "^0.21.1",
81
- "@xchainjs/xchain-bitcoincash": "^0.15.9",
82
- "@xchainjs/xchain-client": "^0.13.6",
80
+ "@xchainjs/xchain-bitcoin": "^0.21.4",
81
+ "@xchainjs/xchain-bitcoincash": "^0.15.11",
82
+ "@xchainjs/xchain-client": "^0.13.7",
83
83
  "@xchainjs/xchain-cosmos": "^0.20.8",
84
84
  "@xchainjs/xchain-crypto": "^0.2.6",
85
- "@xchainjs/xchain-doge": "^0.5.10",
85
+ "@xchainjs/xchain-doge": "^0.5.13",
86
86
  "@xchainjs/xchain-ethereum": "^0.27.7",
87
87
  "@xchainjs/xchain-evm": "^0.1.4",
88
- "@xchainjs/xchain-litecoin": "^0.11.1",
88
+ "@xchainjs/xchain-litecoin": "^0.11.4",
89
89
  "@xchainjs/xchain-midgard": "0.4.3",
90
90
  "@xchainjs/xchain-thorchain": "^0.27.9",
91
- "@xchainjs/xchain-thorchain-query": "^0.2.2",
91
+ "@xchainjs/xchain-thorchain-query": "^0.2.5",
92
92
  "@xchainjs/xchain-thornode": "^0.2.2",
93
93
  "@xchainjs/xchain-util": "^0.12.0",
94
- "@xchainjs/xchain-utxo-providers": "^0.1.1",
94
+ "@xchainjs/xchain-utxo-providers": "^0.1.2",
95
95
  "axios": "^0.25.0",
96
96
  "axios-retry": "^3.2.5",
97
97
  "bchaddrjs": "^0.5.2",