@xchainjs/xchain-thorchain-amm 0.3.1 → 0.3.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/README.md +5 -0
- package/lib/index.esm.js +43 -19
- package/lib/index.js +43 -19
- package/lib/thorchain-amm.d.ts +15 -3
- package/lib/types.d.ts +1 -1
- package/lib/wallet.d.ts +6 -6
- package/package.json +14 -15
package/README.md
CHANGED
|
@@ -54,6 +54,11 @@ Following peer dependencies have to be installed into your project. These are no
|
|
|
54
54
|
[How thorchain-amm works](http://docs.xchainjs.org/xchain-thorchain-amm/how-it-works.html)\
|
|
55
55
|
[How to use thorchain-amm](http://docs.xchainjs.org/xchain-thorchain-amm/how-to-use.html)
|
|
56
56
|
|
|
57
|
+
For live examples
|
|
58
|
+
[Do Swap](https://replit.com/@thorchain/doSwap-Single)
|
|
59
|
+
[Add Liquidity](https://replit.com/@thorchain/addLiquidity)
|
|
60
|
+
[Withdraw liquidity](https://replit.com/@thorchain/removeLiquidity)
|
|
61
|
+
|
|
57
62
|
##
|
|
58
63
|
|
|
59
64
|
tsconfig compiler options
|
package/lib/index.esm.js
CHANGED
|
@@ -11,6 +11,7 @@ import { Client as Client$4 } from '@xchainjs/xchain-thorchain';
|
|
|
11
11
|
import { eqAsset, AssetETH, getContractAddressFromAsset, baseAmount, Chain, assetToString, AssetBTC } from '@xchainjs/xchain-util';
|
|
12
12
|
import { ethers } from 'ethers';
|
|
13
13
|
import { MAX_APPROVAL as MAX_APPROVAL$1 } from '@xchainjs/xchain-evm';
|
|
14
|
+
import { ThorchainQuery } from '@xchainjs/xchain-thorchain-query';
|
|
14
15
|
import { BigNumber } from 'bignumber.js';
|
|
15
16
|
|
|
16
17
|
/*! *****************************************************************************
|
|
@@ -804,7 +805,7 @@ class Wallet {
|
|
|
804
805
|
* @param params - parameters required for liquidity position
|
|
805
806
|
* @returns object with tx response, url and wait time in seconds
|
|
806
807
|
*/
|
|
807
|
-
|
|
808
|
+
withdrawLiquidity(params) {
|
|
808
809
|
return __awaiter(this, void 0, void 0, function* () {
|
|
809
810
|
const assetClient = this.clients[params.assetFee.asset.chain];
|
|
810
811
|
const inboundAsgard = (yield this.thorchainQuery.thorchainCache.getInboundDetails())[params.assetFee.asset.chain]
|
|
@@ -816,21 +817,21 @@ class Wallet {
|
|
|
816
817
|
const txSubmitted = [];
|
|
817
818
|
if (params.assetAddress && params.runeAddress) {
|
|
818
819
|
constructedMemo = `-:${params.assetPool}:${basisPoints}`;
|
|
819
|
-
txSubmitted.push(yield this.
|
|
820
|
+
txSubmitted.push(yield this.withdrawAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
|
|
820
821
|
constructedMemo = `-:${params.assetPool}:${basisPoints}`;
|
|
821
|
-
txSubmitted.push(yield this.
|
|
822
|
+
txSubmitted.push(yield this.withdrawRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
|
|
822
823
|
return txSubmitted;
|
|
823
824
|
}
|
|
824
825
|
else if (params.assetAddress && !params.runeAddress) {
|
|
825
826
|
// asymmetrical asset only
|
|
826
827
|
constructedMemo = `-:${params.assetPool}:${basisPoints}`;
|
|
827
|
-
txSubmitted.push(yield this.
|
|
828
|
+
txSubmitted.push(yield this.withdrawAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
|
|
828
829
|
return txSubmitted;
|
|
829
830
|
}
|
|
830
831
|
else {
|
|
831
832
|
// asymmetrical rune only
|
|
832
833
|
constructedMemo = `-:${params.assetPool}:${basisPoints}`;
|
|
833
|
-
txSubmitted.push(yield this.
|
|
834
|
+
txSubmitted.push(yield this.withdrawRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
|
|
834
835
|
return txSubmitted;
|
|
835
836
|
}
|
|
836
837
|
});
|
|
@@ -890,29 +891,29 @@ class Wallet {
|
|
|
890
891
|
}
|
|
891
892
|
/**
|
|
892
893
|
*
|
|
893
|
-
* @param params - parameters for
|
|
894
|
+
* @param params - parameters for withdraw liquidity
|
|
894
895
|
* @param constructedMemo - memo needed for thorchain execution
|
|
895
896
|
* @param assetClient - asset client to call transfer
|
|
896
897
|
* @param waitTimeSeconds - return back estimated wait
|
|
897
898
|
* @param inboundAsgard - destination address
|
|
898
899
|
* @returns - tx object
|
|
899
900
|
*/
|
|
900
|
-
|
|
901
|
+
withdrawAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard) {
|
|
901
902
|
return __awaiter(this, void 0, void 0, function* () {
|
|
902
903
|
if (params.assetFee.asset.chain === Chain.Ethereum) {
|
|
903
|
-
const
|
|
904
|
+
const withdrawParams = {
|
|
904
905
|
wallIndex: 0,
|
|
905
906
|
asset: params.assetFee.asset,
|
|
906
907
|
amount: params.assetFee.baseAmount,
|
|
907
908
|
feeOption: FeeOption.Fast,
|
|
908
909
|
memo: constructedMemo,
|
|
909
910
|
};
|
|
910
|
-
// console.log(
|
|
911
|
-
const hash = yield this.ethHelper.sendDeposit(
|
|
911
|
+
// console.log(withdrawParams.amount.amount().toNumber())
|
|
912
|
+
const hash = yield this.ethHelper.sendDeposit(withdrawParams);
|
|
912
913
|
return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
|
|
913
914
|
}
|
|
914
915
|
else if (params.assetFee.asset.chain === Chain.Avalanche) {
|
|
915
|
-
const
|
|
916
|
+
const withdrawParams = {
|
|
916
917
|
wallIndex: 0,
|
|
917
918
|
asset: params.assetFee.asset,
|
|
918
919
|
amount: params.assetFee.baseAmount,
|
|
@@ -920,11 +921,11 @@ class Wallet {
|
|
|
920
921
|
memo: constructedMemo,
|
|
921
922
|
};
|
|
922
923
|
const evmHelper = new EvmHelper(this.clients.AVAX, this.thorchainQuery.thorchainCache);
|
|
923
|
-
const hash = yield evmHelper.sendDeposit(
|
|
924
|
+
const hash = yield evmHelper.sendDeposit(withdrawParams);
|
|
924
925
|
return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
|
|
925
926
|
}
|
|
926
927
|
else {
|
|
927
|
-
const
|
|
928
|
+
const withdrawParams = {
|
|
928
929
|
wallIndex: 0,
|
|
929
930
|
asset: params.assetFee.asset,
|
|
930
931
|
amount: params.assetFee.baseAmount,
|
|
@@ -932,7 +933,7 @@ class Wallet {
|
|
|
932
933
|
memo: constructedMemo,
|
|
933
934
|
};
|
|
934
935
|
try {
|
|
935
|
-
const hash = yield assetClient.transfer(
|
|
936
|
+
const hash = yield assetClient.transfer(withdrawParams);
|
|
936
937
|
return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
|
|
937
938
|
}
|
|
938
939
|
catch (err) {
|
|
@@ -963,11 +964,11 @@ class Wallet {
|
|
|
963
964
|
}
|
|
964
965
|
/**
|
|
965
966
|
*
|
|
966
|
-
* @param params -
|
|
967
|
+
* @param params - withdraw parameters
|
|
967
968
|
* @param memo - memo needed to withdraw lp
|
|
968
969
|
* @returns - tx object
|
|
969
970
|
*/
|
|
970
|
-
|
|
971
|
+
withdrawRuneLP(params, memo, thorchainClient, waitTimeSeconds) {
|
|
971
972
|
return __awaiter(this, void 0, void 0, function* () {
|
|
972
973
|
const thorClient = this.clients.THOR;
|
|
973
974
|
const addParams = {
|
|
@@ -983,6 +984,7 @@ class Wallet {
|
|
|
983
984
|
}
|
|
984
985
|
|
|
985
986
|
const BN_1 = new BigNumber(1);
|
|
987
|
+
const defaultQuery = new ThorchainQuery();
|
|
986
988
|
/**
|
|
987
989
|
* THORChain Class for interacting with THORChain.
|
|
988
990
|
* Recommended main class to use for swapping with THORChain
|
|
@@ -995,7 +997,7 @@ class ThorchainAMM {
|
|
|
995
997
|
* @param thorchainQuery - an instance of the ThorchainQuery
|
|
996
998
|
* @returns ThorchainAMM
|
|
997
999
|
*/
|
|
998
|
-
constructor(thorchainQuery) {
|
|
1000
|
+
constructor(thorchainQuery = defaultQuery) {
|
|
999
1001
|
this.thorchainQuery = thorchainQuery;
|
|
1000
1002
|
}
|
|
1001
1003
|
/**
|
|
@@ -1052,6 +1054,26 @@ class ThorchainAMM {
|
|
|
1052
1054
|
});
|
|
1053
1055
|
});
|
|
1054
1056
|
}
|
|
1057
|
+
/**
|
|
1058
|
+
* Wraps estimate from thorchain query
|
|
1059
|
+
* @param params - estimate add liquidity
|
|
1060
|
+
* @returns - Estimate add lp object
|
|
1061
|
+
*/
|
|
1062
|
+
estimateAddLiquidity(params) {
|
|
1063
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1064
|
+
return this.thorchainQuery.estimateAddLP(params);
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
/**
|
|
1068
|
+
* Wraps estimate withdraw from thorchain query
|
|
1069
|
+
* @param params - estimate withdraw liquidity
|
|
1070
|
+
* @returns - Estimate withdraw lp object
|
|
1071
|
+
*/
|
|
1072
|
+
estimateWithdrawLiquidity(params) {
|
|
1073
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1074
|
+
return this.thorchainQuery.estimateWithdrawLP(params);
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1055
1077
|
/**
|
|
1056
1078
|
*
|
|
1057
1079
|
* @param wallet - wallet class
|
|
@@ -1062,6 +1084,8 @@ class ThorchainAMM {
|
|
|
1062
1084
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1063
1085
|
// Check amounts are greater than fees and use return estimated wait
|
|
1064
1086
|
const checkLPAdd = yield this.thorchainQuery.estimateAddLP(params);
|
|
1087
|
+
if (!checkLPAdd.canAdd)
|
|
1088
|
+
throw Error(`${checkLPAdd.errors}`);
|
|
1065
1089
|
return wallet.addLiquidity({
|
|
1066
1090
|
asset: params.asset,
|
|
1067
1091
|
rune: params.rune,
|
|
@@ -1076,11 +1100,11 @@ class ThorchainAMM {
|
|
|
1076
1100
|
* @param wallet - wallet needed to perform tx
|
|
1077
1101
|
* @return
|
|
1078
1102
|
*/
|
|
1079
|
-
|
|
1103
|
+
withdrawLiquidityPosition(wallet, params) {
|
|
1080
1104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1081
1105
|
// Caution Dust Limits: BTC,BCH,LTC chains 10k sats; DOGE 1m Sats; ETH 0 wei; THOR 0 RUNE.
|
|
1082
1106
|
const withdrawParams = yield this.thorchainQuery.estimateWithdrawLP(params);
|
|
1083
|
-
return wallet.
|
|
1107
|
+
return wallet.withdrawLiquidity({
|
|
1084
1108
|
assetFee: withdrawParams.transactionFee.assetFee,
|
|
1085
1109
|
runeFee: withdrawParams.transactionFee.runeFee,
|
|
1086
1110
|
waitTimeSeconds: withdrawParams.estimatedWaitSeconds,
|
package/lib/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var xchainThorchain = require('@xchainjs/xchain-thorchain');
|
|
|
15
15
|
var xchainUtil = require('@xchainjs/xchain-util');
|
|
16
16
|
var ethers = require('ethers');
|
|
17
17
|
var xchainEvm = require('@xchainjs/xchain-evm');
|
|
18
|
+
var xchainThorchainQuery = require('@xchainjs/xchain-thorchain-query');
|
|
18
19
|
var bignumber_js = require('bignumber.js');
|
|
19
20
|
|
|
20
21
|
/*! *****************************************************************************
|
|
@@ -808,7 +809,7 @@ class Wallet {
|
|
|
808
809
|
* @param params - parameters required for liquidity position
|
|
809
810
|
* @returns object with tx response, url and wait time in seconds
|
|
810
811
|
*/
|
|
811
|
-
|
|
812
|
+
withdrawLiquidity(params) {
|
|
812
813
|
return __awaiter(this, void 0, void 0, function* () {
|
|
813
814
|
const assetClient = this.clients[params.assetFee.asset.chain];
|
|
814
815
|
const inboundAsgard = (yield this.thorchainQuery.thorchainCache.getInboundDetails())[params.assetFee.asset.chain]
|
|
@@ -820,21 +821,21 @@ class Wallet {
|
|
|
820
821
|
const txSubmitted = [];
|
|
821
822
|
if (params.assetAddress && params.runeAddress) {
|
|
822
823
|
constructedMemo = `-:${params.assetPool}:${basisPoints}`;
|
|
823
|
-
txSubmitted.push(yield this.
|
|
824
|
+
txSubmitted.push(yield this.withdrawAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
|
|
824
825
|
constructedMemo = `-:${params.assetPool}:${basisPoints}`;
|
|
825
|
-
txSubmitted.push(yield this.
|
|
826
|
+
txSubmitted.push(yield this.withdrawRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
|
|
826
827
|
return txSubmitted;
|
|
827
828
|
}
|
|
828
829
|
else if (params.assetAddress && !params.runeAddress) {
|
|
829
830
|
// asymmetrical asset only
|
|
830
831
|
constructedMemo = `-:${params.assetPool}:${basisPoints}`;
|
|
831
|
-
txSubmitted.push(yield this.
|
|
832
|
+
txSubmitted.push(yield this.withdrawAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
|
|
832
833
|
return txSubmitted;
|
|
833
834
|
}
|
|
834
835
|
else {
|
|
835
836
|
// asymmetrical rune only
|
|
836
837
|
constructedMemo = `-:${params.assetPool}:${basisPoints}`;
|
|
837
|
-
txSubmitted.push(yield this.
|
|
838
|
+
txSubmitted.push(yield this.withdrawRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
|
|
838
839
|
return txSubmitted;
|
|
839
840
|
}
|
|
840
841
|
});
|
|
@@ -894,29 +895,29 @@ class Wallet {
|
|
|
894
895
|
}
|
|
895
896
|
/**
|
|
896
897
|
*
|
|
897
|
-
* @param params - parameters for
|
|
898
|
+
* @param params - parameters for withdraw liquidity
|
|
898
899
|
* @param constructedMemo - memo needed for thorchain execution
|
|
899
900
|
* @param assetClient - asset client to call transfer
|
|
900
901
|
* @param waitTimeSeconds - return back estimated wait
|
|
901
902
|
* @param inboundAsgard - destination address
|
|
902
903
|
* @returns - tx object
|
|
903
904
|
*/
|
|
904
|
-
|
|
905
|
+
withdrawAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard) {
|
|
905
906
|
return __awaiter(this, void 0, void 0, function* () {
|
|
906
907
|
if (params.assetFee.asset.chain === xchainUtil.Chain.Ethereum) {
|
|
907
|
-
const
|
|
908
|
+
const withdrawParams = {
|
|
908
909
|
wallIndex: 0,
|
|
909
910
|
asset: params.assetFee.asset,
|
|
910
911
|
amount: params.assetFee.baseAmount,
|
|
911
912
|
feeOption: xchainClient.FeeOption.Fast,
|
|
912
913
|
memo: constructedMemo,
|
|
913
914
|
};
|
|
914
|
-
// console.log(
|
|
915
|
-
const hash = yield this.ethHelper.sendDeposit(
|
|
915
|
+
// console.log(withdrawParams.amount.amount().toNumber())
|
|
916
|
+
const hash = yield this.ethHelper.sendDeposit(withdrawParams);
|
|
916
917
|
return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
|
|
917
918
|
}
|
|
918
919
|
else if (params.assetFee.asset.chain === xchainUtil.Chain.Avalanche) {
|
|
919
|
-
const
|
|
920
|
+
const withdrawParams = {
|
|
920
921
|
wallIndex: 0,
|
|
921
922
|
asset: params.assetFee.asset,
|
|
922
923
|
amount: params.assetFee.baseAmount,
|
|
@@ -924,11 +925,11 @@ class Wallet {
|
|
|
924
925
|
memo: constructedMemo,
|
|
925
926
|
};
|
|
926
927
|
const evmHelper = new EvmHelper(this.clients.AVAX, this.thorchainQuery.thorchainCache);
|
|
927
|
-
const hash = yield evmHelper.sendDeposit(
|
|
928
|
+
const hash = yield evmHelper.sendDeposit(withdrawParams);
|
|
928
929
|
return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
|
|
929
930
|
}
|
|
930
931
|
else {
|
|
931
|
-
const
|
|
932
|
+
const withdrawParams = {
|
|
932
933
|
wallIndex: 0,
|
|
933
934
|
asset: params.assetFee.asset,
|
|
934
935
|
amount: params.assetFee.baseAmount,
|
|
@@ -936,7 +937,7 @@ class Wallet {
|
|
|
936
937
|
memo: constructedMemo,
|
|
937
938
|
};
|
|
938
939
|
try {
|
|
939
|
-
const hash = yield assetClient.transfer(
|
|
940
|
+
const hash = yield assetClient.transfer(withdrawParams);
|
|
940
941
|
return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
|
|
941
942
|
}
|
|
942
943
|
catch (err) {
|
|
@@ -967,11 +968,11 @@ class Wallet {
|
|
|
967
968
|
}
|
|
968
969
|
/**
|
|
969
970
|
*
|
|
970
|
-
* @param params -
|
|
971
|
+
* @param params - withdraw parameters
|
|
971
972
|
* @param memo - memo needed to withdraw lp
|
|
972
973
|
* @returns - tx object
|
|
973
974
|
*/
|
|
974
|
-
|
|
975
|
+
withdrawRuneLP(params, memo, thorchainClient, waitTimeSeconds) {
|
|
975
976
|
return __awaiter(this, void 0, void 0, function* () {
|
|
976
977
|
const thorClient = this.clients.THOR;
|
|
977
978
|
const addParams = {
|
|
@@ -987,6 +988,7 @@ class Wallet {
|
|
|
987
988
|
}
|
|
988
989
|
|
|
989
990
|
const BN_1 = new bignumber_js.BigNumber(1);
|
|
991
|
+
const defaultQuery = new xchainThorchainQuery.ThorchainQuery();
|
|
990
992
|
/**
|
|
991
993
|
* THORChain Class for interacting with THORChain.
|
|
992
994
|
* Recommended main class to use for swapping with THORChain
|
|
@@ -999,7 +1001,7 @@ class ThorchainAMM {
|
|
|
999
1001
|
* @param thorchainQuery - an instance of the ThorchainQuery
|
|
1000
1002
|
* @returns ThorchainAMM
|
|
1001
1003
|
*/
|
|
1002
|
-
constructor(thorchainQuery) {
|
|
1004
|
+
constructor(thorchainQuery = defaultQuery) {
|
|
1003
1005
|
this.thorchainQuery = thorchainQuery;
|
|
1004
1006
|
}
|
|
1005
1007
|
/**
|
|
@@ -1056,6 +1058,26 @@ class ThorchainAMM {
|
|
|
1056
1058
|
});
|
|
1057
1059
|
});
|
|
1058
1060
|
}
|
|
1061
|
+
/**
|
|
1062
|
+
* Wraps estimate from thorchain query
|
|
1063
|
+
* @param params - estimate add liquidity
|
|
1064
|
+
* @returns - Estimate add lp object
|
|
1065
|
+
*/
|
|
1066
|
+
estimateAddLiquidity(params) {
|
|
1067
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1068
|
+
return this.thorchainQuery.estimateAddLP(params);
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Wraps estimate withdraw from thorchain query
|
|
1073
|
+
* @param params - estimate withdraw liquidity
|
|
1074
|
+
* @returns - Estimate withdraw lp object
|
|
1075
|
+
*/
|
|
1076
|
+
estimateWithdrawLiquidity(params) {
|
|
1077
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1078
|
+
return this.thorchainQuery.estimateWithdrawLP(params);
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1059
1081
|
/**
|
|
1060
1082
|
*
|
|
1061
1083
|
* @param wallet - wallet class
|
|
@@ -1066,6 +1088,8 @@ class ThorchainAMM {
|
|
|
1066
1088
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1067
1089
|
// Check amounts are greater than fees and use return estimated wait
|
|
1068
1090
|
const checkLPAdd = yield this.thorchainQuery.estimateAddLP(params);
|
|
1091
|
+
if (!checkLPAdd.canAdd)
|
|
1092
|
+
throw Error(`${checkLPAdd.errors}`);
|
|
1069
1093
|
return wallet.addLiquidity({
|
|
1070
1094
|
asset: params.asset,
|
|
1071
1095
|
rune: params.rune,
|
|
@@ -1080,11 +1104,11 @@ class ThorchainAMM {
|
|
|
1080
1104
|
* @param wallet - wallet needed to perform tx
|
|
1081
1105
|
* @return
|
|
1082
1106
|
*/
|
|
1083
|
-
|
|
1107
|
+
withdrawLiquidityPosition(wallet, params) {
|
|
1084
1108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1085
1109
|
// Caution Dust Limits: BTC,BCH,LTC chains 10k sats; DOGE 1m Sats; ETH 0 wei; THOR 0 RUNE.
|
|
1086
1110
|
const withdrawParams = yield this.thorchainQuery.estimateWithdrawLP(params);
|
|
1087
|
-
return wallet.
|
|
1111
|
+
return wallet.withdrawLiquidity({
|
|
1088
1112
|
assetFee: withdrawParams.transactionFee.assetFee,
|
|
1089
1113
|
runeFee: withdrawParams.transactionFee.runeFee,
|
|
1090
1114
|
waitTimeSeconds: withdrawParams.estimatedWaitSeconds,
|
package/lib/thorchain-amm.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AddliquidityPosition, EstimateSwapParams,
|
|
1
|
+
import { AddliquidityPosition, EstimateAddLP, EstimateSwapParams, EstimateWithdrawLP, ThorchainQuery, TxDetails, WithdrawLiquidityPosition } from '@xchainjs/xchain-thorchain-query';
|
|
2
2
|
import { TxSubmitted } from './types';
|
|
3
3
|
import { Wallet } from './wallet';
|
|
4
4
|
/**
|
|
@@ -14,7 +14,7 @@ export declare class ThorchainAMM {
|
|
|
14
14
|
* @param thorchainQuery - an instance of the ThorchainQuery
|
|
15
15
|
* @returns ThorchainAMM
|
|
16
16
|
*/
|
|
17
|
-
constructor(thorchainQuery
|
|
17
|
+
constructor(thorchainQuery?: ThorchainQuery);
|
|
18
18
|
/**
|
|
19
19
|
* Provides a swap estimate for the given swap detail. Will check the params for errors before trying to get the estimate.
|
|
20
20
|
* Uses current pool data, works out inbound and outboud fee, affiliate fees and works out the expected wait time for the swap (in and out)
|
|
@@ -32,6 +32,18 @@ export declare class ThorchainAMM {
|
|
|
32
32
|
* @returns {SwapSubmitted} - Tx Hash, URL of BlockExplorer and expected wait time.
|
|
33
33
|
*/
|
|
34
34
|
doSwap(wallet: Wallet, params: EstimateSwapParams): Promise<TxSubmitted>;
|
|
35
|
+
/**
|
|
36
|
+
* Wraps estimate from thorchain query
|
|
37
|
+
* @param params - estimate add liquidity
|
|
38
|
+
* @returns - Estimate add lp object
|
|
39
|
+
*/
|
|
40
|
+
estimateAddLiquidity(params: AddliquidityPosition): Promise<EstimateAddLP>;
|
|
41
|
+
/**
|
|
42
|
+
* Wraps estimate withdraw from thorchain query
|
|
43
|
+
* @param params - estimate withdraw liquidity
|
|
44
|
+
* @returns - Estimate withdraw lp object
|
|
45
|
+
*/
|
|
46
|
+
estimateWithdrawLiquidity(params: WithdrawLiquidityPosition): Promise<EstimateWithdrawLP>;
|
|
35
47
|
/**
|
|
36
48
|
*
|
|
37
49
|
* @param wallet - wallet class
|
|
@@ -45,5 +57,5 @@ export declare class ThorchainAMM {
|
|
|
45
57
|
* @param wallet - wallet needed to perform tx
|
|
46
58
|
* @return
|
|
47
59
|
*/
|
|
48
|
-
|
|
60
|
+
withdrawLiquidityPosition(wallet: Wallet, params: WithdrawLiquidityPosition): Promise<TxSubmitted[]>;
|
|
49
61
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare type AddLiquidity = {
|
|
|
34
34
|
waitTimeSeconds: number;
|
|
35
35
|
assetPool: string;
|
|
36
36
|
};
|
|
37
|
-
export declare type
|
|
37
|
+
export declare type WithdrawLiquidity = {
|
|
38
38
|
assetFee: CryptoAmount;
|
|
39
39
|
runeFee: CryptoAmount;
|
|
40
40
|
waitTimeSeconds: number;
|
package/lib/wallet.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Balance, XChainClient } from '@xchainjs/xchain-client';
|
|
2
2
|
import { ThorchainQuery } from '@xchainjs/xchain-thorchain-query';
|
|
3
3
|
import { Chain } from '@xchainjs/xchain-util';
|
|
4
|
-
import { AddLiquidity, ExecuteSwap,
|
|
4
|
+
import { AddLiquidity, ExecuteSwap, TxSubmitted, WithdrawLiquidity } from './types';
|
|
5
5
|
declare type AllBalances = {
|
|
6
6
|
chain: Chain;
|
|
7
7
|
address: string;
|
|
@@ -51,7 +51,7 @@ export declare class Wallet {
|
|
|
51
51
|
* @param params - parameters required for liquidity position
|
|
52
52
|
* @returns object with tx response, url and wait time in seconds
|
|
53
53
|
*/
|
|
54
|
-
|
|
54
|
+
withdrawLiquidity(params: WithdrawLiquidity): Promise<TxSubmitted[]>;
|
|
55
55
|
/**
|
|
56
56
|
*
|
|
57
57
|
* @param params - parameters for add liquidity
|
|
@@ -64,14 +64,14 @@ export declare class Wallet {
|
|
|
64
64
|
private addAssetLP;
|
|
65
65
|
/**
|
|
66
66
|
*
|
|
67
|
-
* @param params - parameters for
|
|
67
|
+
* @param params - parameters for withdraw liquidity
|
|
68
68
|
* @param constructedMemo - memo needed for thorchain execution
|
|
69
69
|
* @param assetClient - asset client to call transfer
|
|
70
70
|
* @param waitTimeSeconds - return back estimated wait
|
|
71
71
|
* @param inboundAsgard - destination address
|
|
72
72
|
* @returns - tx object
|
|
73
73
|
*/
|
|
74
|
-
private
|
|
74
|
+
private withdrawAssetLP;
|
|
75
75
|
/**
|
|
76
76
|
*
|
|
77
77
|
* @param params - deposit parameters
|
|
@@ -81,10 +81,10 @@ export declare class Wallet {
|
|
|
81
81
|
private addRuneLP;
|
|
82
82
|
/**
|
|
83
83
|
*
|
|
84
|
-
* @param params -
|
|
84
|
+
* @param params - withdraw parameters
|
|
85
85
|
* @param memo - memo needed to withdraw lp
|
|
86
86
|
* @returns - tx object
|
|
87
87
|
*/
|
|
88
|
-
private
|
|
88
|
+
private withdrawRuneLP;
|
|
89
89
|
}
|
|
90
90
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xchainjs/xchain-thorchain-amm",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "module that exposes estimating & swappping cryptocurrency assets on thorchain",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"THORChain",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"@xchainjs/xchain-crypto": "^0.2.6",
|
|
49
49
|
"@xchainjs/xchain-doge": "^0.5.0",
|
|
50
50
|
"@xchainjs/xchain-ethereum": "^0.27.0",
|
|
51
|
-
"@xchainjs/xchain-evm": "^0.1.0
|
|
52
|
-
"@xchainjs/xchain-avax": "^0.1.0
|
|
51
|
+
"@xchainjs/xchain-evm": "^0.1.0",
|
|
52
|
+
"@xchainjs/xchain-avax": "^0.1.0",
|
|
53
53
|
"@xchainjs/xchain-litecoin": "^0.10.3",
|
|
54
54
|
"@xchainjs/xchain-midgard": "0.1.0",
|
|
55
55
|
"@xchainjs/xchain-thorchain": "^0.27.0",
|
|
@@ -73,22 +73,21 @@
|
|
|
73
73
|
"@binance-chain/javascript-sdk": "^4.2.0",
|
|
74
74
|
"@cosmos-client/core": "0.45.13",
|
|
75
75
|
"@psf/bitcoincashjs-lib": "^4.0.2",
|
|
76
|
-
"@
|
|
77
|
-
"@xchainjs/xchain-
|
|
78
|
-
"@xchainjs/xchain-
|
|
79
|
-
"@xchainjs/xchain-bitcoincash": "^0.15.0",
|
|
76
|
+
"@xchainjs/xchain-binance": "^5.6.4",
|
|
77
|
+
"@xchainjs/xchain-bitcoin": "^0.20.4",
|
|
78
|
+
"@xchainjs/xchain-bitcoincash": "^0.15.3",
|
|
80
79
|
"@xchainjs/xchain-client": "^0.13.2",
|
|
81
|
-
"@xchainjs/xchain-cosmos": "^0.20.
|
|
80
|
+
"@xchainjs/xchain-cosmos": "^0.20.3",
|
|
82
81
|
"@xchainjs/xchain-crypto": "^0.2.6",
|
|
83
|
-
"@xchainjs/xchain-doge": "^0.5.
|
|
84
|
-
"@xchainjs/xchain-ethereum": "^0.27.
|
|
85
|
-
"@xchainjs/xchain-evm": "^0.1.0
|
|
86
|
-
"@xchainjs/xchain-avax": "^0.1.0
|
|
87
|
-
"@xchainjs/xchain-litecoin": "^0.10.
|
|
82
|
+
"@xchainjs/xchain-doge": "^0.5.4",
|
|
83
|
+
"@xchainjs/xchain-ethereum": "^0.27.3",
|
|
84
|
+
"@xchainjs/xchain-evm": "^0.1.0",
|
|
85
|
+
"@xchainjs/xchain-avax": "^0.1.0",
|
|
86
|
+
"@xchainjs/xchain-litecoin": "^0.10.4",
|
|
88
87
|
"@xchainjs/xchain-midgard": "0.1.0",
|
|
89
88
|
"@xchainjs/xchain-thornode": "^0.1.0",
|
|
90
|
-
"@xchainjs/xchain-thorchain": "^0.
|
|
91
|
-
"@xchainjs/xchain-thorchain-query": "^0.1.
|
|
89
|
+
"@xchainjs/xchain-thorchain": "^0.27.1",
|
|
90
|
+
"@xchainjs/xchain-thorchain-query": "^0.1.2",
|
|
92
91
|
"@xchainjs/xchain-util": "^0.11.0",
|
|
93
92
|
"axios": "^0.25.0",
|
|
94
93
|
"axios-retry": "^3.2.5",
|