@xchainjs/xchain-thorchain-amm 0.3.0 → 0.3.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/README.md CHANGED
@@ -28,11 +28,11 @@ Following peer dependencies have to be installed into your project. These are no
28
28
  "@xchainjs/xchain-ethereum": "^0.27.0",
29
29
  "@xchainjs/xchain-evm": "^0.1.0-alpha2",
30
30
  "@xchainjs/xchain-avax": "^0.1.0-alpha3",
31
- "@xchainjs/xchain-litecoin": "^0.10.0",
31
+ "@xchainjs/xchain-litecoin": "^0.10.3",
32
32
  "@xchainjs/xchain-midgard": "^0.1.0",
33
33
  "@xchainjs/xchain-terra": "^0.3.0",
34
34
  "@xchainjs/xchain-thorchain": "^0.26.0",
35
- "@xchainjs/xchain-thorchain-query": "^0.1.0",
35
+ "@xchainjs/xchain-thorchain-query": "^0.1.2",
36
36
  "@xchainjs/xchain-thornode": "^0.1.0",
37
37
  "@xchainjs/xchain-util": "^0.9.0",
38
38
  "axios": "^0.27.2",
package/lib/index.esm.js CHANGED
@@ -779,22 +779,22 @@ class Wallet {
779
779
  const txSubmitted = [];
780
780
  // symmetrical add
781
781
  if (params.asset.assetAmount.gt(0) && params.rune.assetAmount.gt(0)) {
782
- constructedMemo = `+:${params.asset.asset.chain}.${params.asset.asset.symbol}:${addressRune}`;
783
- txSubmitted.push(yield this.addOrRemoveAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
784
- constructedMemo = `+:${params.asset.asset.chain}.${params.asset.asset.symbol}:${addressAsset}`;
785
- txSubmitted.push(yield this.addOrRemoveRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
782
+ constructedMemo = `+:${params.assetPool}:${addressRune}`;
783
+ txSubmitted.push(yield this.addAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
784
+ constructedMemo = `+:${params.assetPool}:${addressAsset}`;
785
+ txSubmitted.push(yield this.addRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
786
786
  return txSubmitted;
787
787
  }
788
788
  else if (params.asset.assetAmount.gt(0) && params.rune.assetAmount.eq(0)) {
789
789
  // asymmetrical asset only
790
- constructedMemo = `+:${params.asset.asset.chain}.${params.asset.asset.symbol}`;
791
- txSubmitted.push(yield this.addOrRemoveAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
790
+ constructedMemo = `+:${params.assetPool}`;
791
+ txSubmitted.push(yield this.addAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
792
792
  return txSubmitted;
793
793
  }
794
794
  else {
795
795
  // asymmetrical rune only
796
- constructedMemo = `+:${params.asset.asset.chain}.${params.asset.asset.symbol}`;
797
- txSubmitted.push(yield this.addOrRemoveRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
796
+ constructedMemo = `+:${params.assetPool}`;
797
+ txSubmitted.push(yield this.addRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
798
798
  return txSubmitted;
799
799
  }
800
800
  });
@@ -806,33 +806,31 @@ class Wallet {
806
806
  */
807
807
  removeLiquidity(params) {
808
808
  return __awaiter(this, void 0, void 0, function* () {
809
- const assetClient = this.clients[params.asset.asset.chain];
810
- const inboundAsgard = (yield this.thorchainQuery.thorchainCache.getInboundDetails())[params.asset.asset.chain];
811
- if (!(inboundAsgard === null || inboundAsgard === void 0 ? void 0 : inboundAsgard.address)) {
812
- throw new Error('Vault address is not defined');
813
- }
809
+ const assetClient = this.clients[params.assetFee.asset.chain];
810
+ const inboundAsgard = (yield this.thorchainQuery.thorchainCache.getInboundDetails())[params.assetFee.asset.chain]
811
+ .address;
814
812
  const waitTimeSeconds = params.waitTimeSeconds;
815
- const thorchainClient = this.clients[params.rune.asset.chain];
813
+ const thorchainClient = this.clients[params.runeFee.asset.chain];
816
814
  const basisPoints = (params.percentage * 100).toFixed(); // convert to basis points
817
815
  let constructedMemo = '';
818
816
  const txSubmitted = [];
819
- if (params.asset.assetAmount.gt(0) && params.rune.assetAmount.gt(0)) {
820
- constructedMemo = `-:${params.asset.asset.chain}.${params.asset.asset.symbol}:${basisPoints}`;
821
- txSubmitted.push(yield this.addOrRemoveAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard.address));
822
- constructedMemo = `-:${params.asset.asset.chain}.${params.asset.asset.symbol}:${basisPoints}`;
823
- txSubmitted.push(yield this.addOrRemoveRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
817
+ if (params.assetAddress && params.runeAddress) {
818
+ constructedMemo = `-:${params.assetPool}:${basisPoints}`;
819
+ txSubmitted.push(yield this.removeAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
820
+ constructedMemo = `-:${params.assetPool}:${basisPoints}`;
821
+ txSubmitted.push(yield this.removeRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
824
822
  return txSubmitted;
825
823
  }
826
- else if (params.asset.assetAmount.gt(0) && params.rune.assetAmount.eq(0)) {
824
+ else if (params.assetAddress && !params.runeAddress) {
827
825
  // asymmetrical asset only
828
- constructedMemo = `-:${params.asset.asset.chain}.${params.asset.asset.symbol}:${basisPoints}`;
829
- txSubmitted.push(yield this.addOrRemoveAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard.address));
826
+ constructedMemo = `-:${params.assetPool}:${basisPoints}`;
827
+ txSubmitted.push(yield this.removeAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
830
828
  return txSubmitted;
831
829
  }
832
830
  else {
833
831
  // asymmetrical rune only
834
- constructedMemo = `-:${params.asset.asset.chain}.${params.asset.asset.symbol}:${basisPoints}`;
835
- txSubmitted.push(yield this.addOrRemoveRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
832
+ constructedMemo = `-:${params.assetPool}:${basisPoints}`;
833
+ txSubmitted.push(yield this.removeRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
836
834
  return txSubmitted;
837
835
  }
838
836
  });
@@ -846,7 +844,7 @@ class Wallet {
846
844
  * @param inboundAsgard - inbound Asgard address for the LP
847
845
  * @returns - tx object
848
846
  */
849
- addOrRemoveAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard) {
847
+ addAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard) {
850
848
  return __awaiter(this, void 0, void 0, function* () {
851
849
  if (params.asset.asset.chain === Chain.Ethereum) {
852
850
  const addParams = {
@@ -856,7 +854,6 @@ class Wallet {
856
854
  feeOption: FeeOption.Fast,
857
855
  memo: constructedMemo,
858
856
  };
859
- console.log(addParams.amount.amount().toNumber());
860
857
  const hash = yield this.ethHelper.sendDeposit(addParams);
861
858
  return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
862
859
  }
@@ -881,7 +878,6 @@ class Wallet {
881
878
  memo: constructedMemo,
882
879
  };
883
880
  try {
884
- console.log(addParams);
885
881
  const hash = yield assetClient.transfer(addParams);
886
882
  return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
887
883
  }
@@ -892,13 +888,67 @@ class Wallet {
892
888
  }
893
889
  });
894
890
  }
891
+ /**
892
+ *
893
+ * @param params - parameters for remove liquidity
894
+ * @param constructedMemo - memo needed for thorchain execution
895
+ * @param assetClient - asset client to call transfer
896
+ * @param waitTimeSeconds - return back estimated wait
897
+ * @param inboundAsgard - destination address
898
+ * @returns - tx object
899
+ */
900
+ removeAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard) {
901
+ return __awaiter(this, void 0, void 0, function* () {
902
+ if (params.assetFee.asset.chain === Chain.Ethereum) {
903
+ const removeParams = {
904
+ wallIndex: 0,
905
+ asset: params.assetFee.asset,
906
+ amount: params.assetFee.baseAmount,
907
+ feeOption: FeeOption.Fast,
908
+ memo: constructedMemo,
909
+ };
910
+ // console.log(removeParams.amount.amount().toNumber())
911
+ const hash = yield this.ethHelper.sendDeposit(removeParams);
912
+ return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
913
+ }
914
+ else if (params.assetFee.asset.chain === Chain.Avalanche) {
915
+ const removeParams = {
916
+ wallIndex: 0,
917
+ asset: params.assetFee.asset,
918
+ amount: params.assetFee.baseAmount,
919
+ feeOption: FeeOption.Fast,
920
+ memo: constructedMemo,
921
+ };
922
+ const evmHelper = new EvmHelper(this.clients.AVAX, this.thorchainQuery.thorchainCache);
923
+ const hash = yield evmHelper.sendDeposit(removeParams);
924
+ return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
925
+ }
926
+ else {
927
+ const removeParams = {
928
+ wallIndex: 0,
929
+ asset: params.assetFee.asset,
930
+ amount: params.assetFee.baseAmount,
931
+ recipient: inboundAsgard,
932
+ memo: constructedMemo,
933
+ };
934
+ try {
935
+ const hash = yield assetClient.transfer(removeParams);
936
+ return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
937
+ }
938
+ catch (err) {
939
+ const hash = JSON.stringify(err);
940
+ return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()), waitTimeSeconds };
941
+ }
942
+ }
943
+ });
944
+ }
895
945
  /**
896
946
  *
897
947
  * @param params - deposit parameters
898
948
  * @param memo - memo needed to withdraw lp
899
949
  * @returns - tx object
900
950
  */
901
- addOrRemoveRuneLP(params, memo, thorchainClient, waitTimeSeconds) {
951
+ addRuneLP(params, memo, thorchainClient, waitTimeSeconds) {
902
952
  return __awaiter(this, void 0, void 0, function* () {
903
953
  const thorClient = this.clients.THOR;
904
954
  const addParams = {
@@ -906,7 +956,26 @@ class Wallet {
906
956
  amount: params.rune.baseAmount,
907
957
  memo: memo,
908
958
  };
909
- console.log(addParams);
959
+ // console.log(addParams)
960
+ const hash = yield thorClient.deposit(addParams);
961
+ return { hash, url: thorchainClient.getExplorerTxUrl(hash), waitTimeSeconds };
962
+ });
963
+ }
964
+ /**
965
+ *
966
+ * @param params - remove parameters
967
+ * @param memo - memo needed to withdraw lp
968
+ * @returns - tx object
969
+ */
970
+ removeRuneLP(params, memo, thorchainClient, waitTimeSeconds) {
971
+ return __awaiter(this, void 0, void 0, function* () {
972
+ const thorClient = this.clients.THOR;
973
+ const addParams = {
974
+ asset: params.runeFee.asset,
975
+ amount: params.runeFee.baseAmount,
976
+ memo: memo,
977
+ };
978
+ // console.log(addParams)
910
979
  const hash = yield thorClient.deposit(addParams);
911
980
  return { hash, url: thorchainClient.getExplorerTxUrl(hash), waitTimeSeconds };
912
981
  });
@@ -997,6 +1066,7 @@ class ThorchainAMM {
997
1066
  asset: params.asset,
998
1067
  rune: params.rune,
999
1068
  waitTimeSeconds: checkLPAdd.estimatedWaitSeconds,
1069
+ assetPool: checkLPAdd.assetPool,
1000
1070
  });
1001
1071
  });
1002
1072
  }
@@ -1009,12 +1079,15 @@ class ThorchainAMM {
1009
1079
  removeLiquidityPosition(wallet, params) {
1010
1080
  return __awaiter(this, void 0, void 0, function* () {
1011
1081
  // Caution Dust Limits: BTC,BCH,LTC chains 10k sats; DOGE 1m Sats; ETH 0 wei; THOR 0 RUNE.
1012
- const estimateWithrawLp = yield this.thorchainQuery.estimateWithdrawLP(params);
1082
+ const withdrawParams = yield this.thorchainQuery.estimateWithdrawLP(params);
1013
1083
  return wallet.removeLiquidity({
1014
- asset: estimateWithrawLp.transactionFee.assetFee,
1015
- rune: estimateWithrawLp.transactionFee.runeFee,
1084
+ assetFee: withdrawParams.transactionFee.assetFee,
1085
+ runeFee: withdrawParams.transactionFee.runeFee,
1086
+ waitTimeSeconds: withdrawParams.estimatedWaitSeconds,
1016
1087
  percentage: params.percentage,
1017
- waitTimeSeconds: estimateWithrawLp.estimatedWaitSeconds,
1088
+ assetPool: withdrawParams.assetPool,
1089
+ assetAddress: withdrawParams.assetAddress,
1090
+ runeAddress: withdrawParams.runeAddress,
1018
1091
  });
1019
1092
  });
1020
1093
  }
package/lib/index.js CHANGED
@@ -783,22 +783,22 @@ class Wallet {
783
783
  const txSubmitted = [];
784
784
  // symmetrical add
785
785
  if (params.asset.assetAmount.gt(0) && params.rune.assetAmount.gt(0)) {
786
- constructedMemo = `+:${params.asset.asset.chain}.${params.asset.asset.symbol}:${addressRune}`;
787
- txSubmitted.push(yield this.addOrRemoveAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
788
- constructedMemo = `+:${params.asset.asset.chain}.${params.asset.asset.symbol}:${addressAsset}`;
789
- txSubmitted.push(yield this.addOrRemoveRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
786
+ constructedMemo = `+:${params.assetPool}:${addressRune}`;
787
+ txSubmitted.push(yield this.addAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
788
+ constructedMemo = `+:${params.assetPool}:${addressAsset}`;
789
+ txSubmitted.push(yield this.addRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
790
790
  return txSubmitted;
791
791
  }
792
792
  else if (params.asset.assetAmount.gt(0) && params.rune.assetAmount.eq(0)) {
793
793
  // asymmetrical asset only
794
- constructedMemo = `+:${params.asset.asset.chain}.${params.asset.asset.symbol}`;
795
- txSubmitted.push(yield this.addOrRemoveAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
794
+ constructedMemo = `+:${params.assetPool}`;
795
+ txSubmitted.push(yield this.addAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
796
796
  return txSubmitted;
797
797
  }
798
798
  else {
799
799
  // asymmetrical rune only
800
- constructedMemo = `+:${params.asset.asset.chain}.${params.asset.asset.symbol}`;
801
- txSubmitted.push(yield this.addOrRemoveRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
800
+ constructedMemo = `+:${params.assetPool}`;
801
+ txSubmitted.push(yield this.addRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
802
802
  return txSubmitted;
803
803
  }
804
804
  });
@@ -810,33 +810,31 @@ class Wallet {
810
810
  */
811
811
  removeLiquidity(params) {
812
812
  return __awaiter(this, void 0, void 0, function* () {
813
- const assetClient = this.clients[params.asset.asset.chain];
814
- const inboundAsgard = (yield this.thorchainQuery.thorchainCache.getInboundDetails())[params.asset.asset.chain];
815
- if (!(inboundAsgard === null || inboundAsgard === void 0 ? void 0 : inboundAsgard.address)) {
816
- throw new Error('Vault address is not defined');
817
- }
813
+ const assetClient = this.clients[params.assetFee.asset.chain];
814
+ const inboundAsgard = (yield this.thorchainQuery.thorchainCache.getInboundDetails())[params.assetFee.asset.chain]
815
+ .address;
818
816
  const waitTimeSeconds = params.waitTimeSeconds;
819
- const thorchainClient = this.clients[params.rune.asset.chain];
817
+ const thorchainClient = this.clients[params.runeFee.asset.chain];
820
818
  const basisPoints = (params.percentage * 100).toFixed(); // convert to basis points
821
819
  let constructedMemo = '';
822
820
  const txSubmitted = [];
823
- if (params.asset.assetAmount.gt(0) && params.rune.assetAmount.gt(0)) {
824
- constructedMemo = `-:${params.asset.asset.chain}.${params.asset.asset.symbol}:${basisPoints}`;
825
- txSubmitted.push(yield this.addOrRemoveAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard.address));
826
- constructedMemo = `-:${params.asset.asset.chain}.${params.asset.asset.symbol}:${basisPoints}`;
827
- txSubmitted.push(yield this.addOrRemoveRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
821
+ if (params.assetAddress && params.runeAddress) {
822
+ constructedMemo = `-:${params.assetPool}:${basisPoints}`;
823
+ txSubmitted.push(yield this.removeAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
824
+ constructedMemo = `-:${params.assetPool}:${basisPoints}`;
825
+ txSubmitted.push(yield this.removeRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
828
826
  return txSubmitted;
829
827
  }
830
- else if (params.asset.assetAmount.gt(0) && params.rune.assetAmount.eq(0)) {
828
+ else if (params.assetAddress && !params.runeAddress) {
831
829
  // asymmetrical asset only
832
- constructedMemo = `-:${params.asset.asset.chain}.${params.asset.asset.symbol}:${basisPoints}`;
833
- txSubmitted.push(yield this.addOrRemoveAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard.address));
830
+ constructedMemo = `-:${params.assetPool}:${basisPoints}`;
831
+ txSubmitted.push(yield this.removeAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
834
832
  return txSubmitted;
835
833
  }
836
834
  else {
837
835
  // asymmetrical rune only
838
- constructedMemo = `-:${params.asset.asset.chain}.${params.asset.asset.symbol}:${basisPoints}`;
839
- txSubmitted.push(yield this.addOrRemoveRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
836
+ constructedMemo = `-:${params.assetPool}:${basisPoints}`;
837
+ txSubmitted.push(yield this.removeRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
840
838
  return txSubmitted;
841
839
  }
842
840
  });
@@ -850,7 +848,7 @@ class Wallet {
850
848
  * @param inboundAsgard - inbound Asgard address for the LP
851
849
  * @returns - tx object
852
850
  */
853
- addOrRemoveAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard) {
851
+ addAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard) {
854
852
  return __awaiter(this, void 0, void 0, function* () {
855
853
  if (params.asset.asset.chain === xchainUtil.Chain.Ethereum) {
856
854
  const addParams = {
@@ -860,7 +858,6 @@ class Wallet {
860
858
  feeOption: xchainClient.FeeOption.Fast,
861
859
  memo: constructedMemo,
862
860
  };
863
- console.log(addParams.amount.amount().toNumber());
864
861
  const hash = yield this.ethHelper.sendDeposit(addParams);
865
862
  return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
866
863
  }
@@ -885,7 +882,6 @@ class Wallet {
885
882
  memo: constructedMemo,
886
883
  };
887
884
  try {
888
- console.log(addParams);
889
885
  const hash = yield assetClient.transfer(addParams);
890
886
  return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
891
887
  }
@@ -896,13 +892,67 @@ class Wallet {
896
892
  }
897
893
  });
898
894
  }
895
+ /**
896
+ *
897
+ * @param params - parameters for remove liquidity
898
+ * @param constructedMemo - memo needed for thorchain execution
899
+ * @param assetClient - asset client to call transfer
900
+ * @param waitTimeSeconds - return back estimated wait
901
+ * @param inboundAsgard - destination address
902
+ * @returns - tx object
903
+ */
904
+ removeAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard) {
905
+ return __awaiter(this, void 0, void 0, function* () {
906
+ if (params.assetFee.asset.chain === xchainUtil.Chain.Ethereum) {
907
+ const removeParams = {
908
+ wallIndex: 0,
909
+ asset: params.assetFee.asset,
910
+ amount: params.assetFee.baseAmount,
911
+ feeOption: xchainClient.FeeOption.Fast,
912
+ memo: constructedMemo,
913
+ };
914
+ // console.log(removeParams.amount.amount().toNumber())
915
+ const hash = yield this.ethHelper.sendDeposit(removeParams);
916
+ return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
917
+ }
918
+ else if (params.assetFee.asset.chain === xchainUtil.Chain.Avalanche) {
919
+ const removeParams = {
920
+ wallIndex: 0,
921
+ asset: params.assetFee.asset,
922
+ amount: params.assetFee.baseAmount,
923
+ feeOption: xchainClient.FeeOption.Fast,
924
+ memo: constructedMemo,
925
+ };
926
+ const evmHelper = new EvmHelper(this.clients.AVAX, this.thorchainQuery.thorchainCache);
927
+ const hash = yield evmHelper.sendDeposit(removeParams);
928
+ return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
929
+ }
930
+ else {
931
+ const removeParams = {
932
+ wallIndex: 0,
933
+ asset: params.assetFee.asset,
934
+ amount: params.assetFee.baseAmount,
935
+ recipient: inboundAsgard,
936
+ memo: constructedMemo,
937
+ };
938
+ try {
939
+ const hash = yield assetClient.transfer(removeParams);
940
+ return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
941
+ }
942
+ catch (err) {
943
+ const hash = JSON.stringify(err);
944
+ return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()), waitTimeSeconds };
945
+ }
946
+ }
947
+ });
948
+ }
899
949
  /**
900
950
  *
901
951
  * @param params - deposit parameters
902
952
  * @param memo - memo needed to withdraw lp
903
953
  * @returns - tx object
904
954
  */
905
- addOrRemoveRuneLP(params, memo, thorchainClient, waitTimeSeconds) {
955
+ addRuneLP(params, memo, thorchainClient, waitTimeSeconds) {
906
956
  return __awaiter(this, void 0, void 0, function* () {
907
957
  const thorClient = this.clients.THOR;
908
958
  const addParams = {
@@ -910,7 +960,26 @@ class Wallet {
910
960
  amount: params.rune.baseAmount,
911
961
  memo: memo,
912
962
  };
913
- console.log(addParams);
963
+ // console.log(addParams)
964
+ const hash = yield thorClient.deposit(addParams);
965
+ return { hash, url: thorchainClient.getExplorerTxUrl(hash), waitTimeSeconds };
966
+ });
967
+ }
968
+ /**
969
+ *
970
+ * @param params - remove parameters
971
+ * @param memo - memo needed to withdraw lp
972
+ * @returns - tx object
973
+ */
974
+ removeRuneLP(params, memo, thorchainClient, waitTimeSeconds) {
975
+ return __awaiter(this, void 0, void 0, function* () {
976
+ const thorClient = this.clients.THOR;
977
+ const addParams = {
978
+ asset: params.runeFee.asset,
979
+ amount: params.runeFee.baseAmount,
980
+ memo: memo,
981
+ };
982
+ // console.log(addParams)
914
983
  const hash = yield thorClient.deposit(addParams);
915
984
  return { hash, url: thorchainClient.getExplorerTxUrl(hash), waitTimeSeconds };
916
985
  });
@@ -1001,6 +1070,7 @@ class ThorchainAMM {
1001
1070
  asset: params.asset,
1002
1071
  rune: params.rune,
1003
1072
  waitTimeSeconds: checkLPAdd.estimatedWaitSeconds,
1073
+ assetPool: checkLPAdd.assetPool,
1004
1074
  });
1005
1075
  });
1006
1076
  }
@@ -1013,12 +1083,15 @@ class ThorchainAMM {
1013
1083
  removeLiquidityPosition(wallet, params) {
1014
1084
  return __awaiter(this, void 0, void 0, function* () {
1015
1085
  // Caution Dust Limits: BTC,BCH,LTC chains 10k sats; DOGE 1m Sats; ETH 0 wei; THOR 0 RUNE.
1016
- const estimateWithrawLp = yield this.thorchainQuery.estimateWithdrawLP(params);
1086
+ const withdrawParams = yield this.thorchainQuery.estimateWithdrawLP(params);
1017
1087
  return wallet.removeLiquidity({
1018
- asset: estimateWithrawLp.transactionFee.assetFee,
1019
- rune: estimateWithrawLp.transactionFee.runeFee,
1088
+ assetFee: withdrawParams.transactionFee.assetFee,
1089
+ runeFee: withdrawParams.transactionFee.runeFee,
1090
+ waitTimeSeconds: withdrawParams.estimatedWaitSeconds,
1020
1091
  percentage: params.percentage,
1021
- waitTimeSeconds: estimateWithrawLp.estimatedWaitSeconds,
1092
+ assetPool: withdrawParams.assetPool,
1093
+ assetAddress: withdrawParams.assetAddress,
1094
+ runeAddress: withdrawParams.runeAddress,
1022
1095
  });
1023
1096
  });
1024
1097
  }
package/lib/types.d.ts CHANGED
@@ -22,23 +22,26 @@ export declare type TxSubmitted = {
22
22
  url: string;
23
23
  waitTimeSeconds: number;
24
24
  };
25
- export declare type AddLiquidity = {
26
- asset: CryptoAmount;
27
- rune: CryptoAmount;
28
- waitTimeSeconds: number;
29
- };
30
25
  export declare type LiquidityPosition = {
31
26
  assetPool: LiquidityPool;
32
27
  assetAmount: CryptoAmount;
33
28
  runeAmount: CryptoAmount;
34
29
  impermanentLossProtection: number;
35
30
  };
36
- export declare type RemoveLiquidity = {
31
+ export declare type AddLiquidity = {
37
32
  asset: CryptoAmount;
38
33
  rune: CryptoAmount;
39
- percentage: number;
40
34
  waitTimeSeconds: number;
41
- asymmetricalWithdraw?: Asset;
35
+ assetPool: string;
36
+ };
37
+ export declare type RemoveLiquidity = {
38
+ assetFee: CryptoAmount;
39
+ runeFee: CryptoAmount;
40
+ waitTimeSeconds: number;
41
+ percentage: number;
42
+ assetPool: string;
43
+ assetAddress?: string;
44
+ runeAddress?: string;
42
45
  };
43
46
  export declare type DepositParams = {
44
47
  walletIndex?: number;
package/lib/wallet.d.ts CHANGED
@@ -61,13 +61,30 @@ export declare class Wallet {
61
61
  * @param inboundAsgard - inbound Asgard address for the LP
62
62
  * @returns - tx object
63
63
  */
64
- private addOrRemoveAssetLP;
64
+ private addAssetLP;
65
+ /**
66
+ *
67
+ * @param params - parameters for remove liquidity
68
+ * @param constructedMemo - memo needed for thorchain execution
69
+ * @param assetClient - asset client to call transfer
70
+ * @param waitTimeSeconds - return back estimated wait
71
+ * @param inboundAsgard - destination address
72
+ * @returns - tx object
73
+ */
74
+ private removeAssetLP;
65
75
  /**
66
76
  *
67
77
  * @param params - deposit parameters
68
78
  * @param memo - memo needed to withdraw lp
69
79
  * @returns - tx object
70
80
  */
71
- private addOrRemoveRuneLP;
81
+ private addRuneLP;
82
+ /**
83
+ *
84
+ * @param params - remove parameters
85
+ * @param memo - memo needed to withdraw lp
86
+ * @returns - tx object
87
+ */
88
+ private removeRuneLP;
72
89
  }
73
90
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-thorchain-amm",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "module that exposes estimating & swappping cryptocurrency assets on thorchain",
5
5
  "keywords": [
6
6
  "THORChain",
@@ -50,10 +50,10 @@
50
50
  "@xchainjs/xchain-ethereum": "^0.27.0",
51
51
  "@xchainjs/xchain-evm": "^0.1.0-alpha2",
52
52
  "@xchainjs/xchain-avax": "^0.1.0-alpha3",
53
- "@xchainjs/xchain-litecoin": "^0.10.0",
53
+ "@xchainjs/xchain-litecoin": "^0.10.3",
54
54
  "@xchainjs/xchain-midgard": "0.1.0",
55
55
  "@xchainjs/xchain-thorchain": "^0.27.0",
56
- "@xchainjs/xchain-thorchain-query": "^0.1.0",
56
+ "@xchainjs/xchain-thorchain-query": "^0.1.2",
57
57
  "@xchainjs/xchain-thornode": "^0.1.0",
58
58
  "@xchainjs/xchain-util": "^0.11.0",
59
59
  "axios": "^0.25.0",