@xchainjs/xchain-thorchain-amm 0.8.21 → 1.0.0
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.d.ts +10 -1
- package/lib/index.esm.js +371 -895
- package/lib/index.js +358 -883
- package/lib/thorchain-action.d.ts +21 -0
- package/lib/thorchain-amm.d.ts +78 -71
- package/lib/types.d.ts +38 -0
- package/lib/utils.d.ts +19 -0
- package/package.json +12 -18
- package/lib/utils/evm-helper.d.ts +0 -25
- package/lib/utils/index.d.ts +0 -1
- package/lib/wallet.d.ts +0 -173
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Address, CryptoAmount } from '@xchainjs/xchain-util';
|
|
2
|
+
import { Wallet } from '@xchainjs/xchain-wallet';
|
|
3
|
+
import { TxSubmitted } from './types';
|
|
4
|
+
export type NonProtocolActionParams = {
|
|
5
|
+
wallet: Wallet;
|
|
6
|
+
assetAmount: CryptoAmount;
|
|
7
|
+
recipient: Address;
|
|
8
|
+
memo: string;
|
|
9
|
+
};
|
|
10
|
+
export type ProtocolActionParams = {
|
|
11
|
+
wallet: Wallet;
|
|
12
|
+
assetAmount: CryptoAmount;
|
|
13
|
+
memo: string;
|
|
14
|
+
};
|
|
15
|
+
export type ActionParams = ProtocolActionParams | NonProtocolActionParams;
|
|
16
|
+
export declare class ThorchainAction {
|
|
17
|
+
static makeAction(actionParams: ActionParams): Promise<TxSubmitted>;
|
|
18
|
+
private static makeProtocolAction;
|
|
19
|
+
private static makeNonProtocolAction;
|
|
20
|
+
private static isNonProtocolParams;
|
|
21
|
+
}
|
package/lib/thorchain-amm.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { AddliquidityPosition, EstimateAddLP, EstimateAddSaver, EstimateWithdrawLP, EstimateWithdrawSaver, LoanCloseParams, LoanCloseQuote, LoanOpenParams, LoanOpenQuote, QuoteSwapParams, SaversPosition, SaversWithdraw, ThorchainQuery, TxDetails, WithdrawLiquidityPosition, getSaver } from '@xchainjs/xchain-thorchain-query';
|
|
2
2
|
import { CryptoAmount } from '@xchainjs/xchain-util';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export type AmmEstimateSwapParams = QuoteSwapParams & {
|
|
6
|
-
wallet: Wallet;
|
|
7
|
-
walletIndex: number;
|
|
8
|
-
};
|
|
3
|
+
import { Wallet } from '@xchainjs/xchain-wallet';
|
|
4
|
+
import { IsApprovedParams, TxSubmitted } from './types';
|
|
9
5
|
/**
|
|
10
6
|
* THORChain Class for interacting with THORChain.
|
|
11
7
|
* Recommended main class to use for swapping with THORChain
|
|
@@ -13,118 +9,129 @@ export type AmmEstimateSwapParams = QuoteSwapParams & {
|
|
|
13
9
|
*/
|
|
14
10
|
export declare class ThorchainAMM {
|
|
15
11
|
private thorchainQuery;
|
|
12
|
+
private wallet;
|
|
16
13
|
/**
|
|
17
|
-
*
|
|
14
|
+
* Constructor to create a ThorchainAMM instance
|
|
18
15
|
*
|
|
19
16
|
* @param thorchainQuery - an instance of the ThorchainQuery
|
|
20
17
|
* @returns ThorchainAMM
|
|
21
18
|
*/
|
|
22
|
-
constructor(thorchainQuery?: ThorchainQuery);
|
|
19
|
+
constructor(thorchainQuery?: ThorchainQuery, wallet?: Wallet);
|
|
23
20
|
/**
|
|
24
|
-
* Provides
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
21
|
+
* * Provides an estimate for a swap based on the given swap details.
|
|
22
|
+
* Checks the parameters for errors before attempting to retrieve the estimate.
|
|
23
|
+
* Utilizes current pool data to calculate inbound and outbound fees, affiliate fees,
|
|
24
|
+
* and the expected wait time for the swap (inbound and outbound).
|
|
25
|
+
* @param params Parameters for the swap, including the amount to swap.
|
|
28
26
|
|
|
29
|
-
* @returns The
|
|
27
|
+
* @returns The estimated swap details.
|
|
28
|
+
*/
|
|
29
|
+
estimateSwap({ fromAddress, fromAsset, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, toleranceBps, }: QuoteSwapParams): Promise<TxDetails>;
|
|
30
|
+
/**
|
|
31
|
+
* Validate swap params
|
|
32
|
+
* @param {QuoteSwapParams} quoteSwapParams Swap params
|
|
33
|
+
* @returns {string[]} the reasons the swap can not be done. If it is empty there are no reason to avoid the swap
|
|
30
34
|
*/
|
|
31
|
-
|
|
35
|
+
validateSwap({ fromAsset, fromAddress, destinationAsset, destinationAddress, amount, affiliateAddress, affiliateBps, }: QuoteSwapParams): Promise<string[]>;
|
|
32
36
|
/**
|
|
33
|
-
* Conducts a swap with the given inputs.
|
|
37
|
+
* Conducts a swap with the given inputs. This method should be called after estimateSwap() to ensure the swap is valid.
|
|
34
38
|
*
|
|
35
|
-
* @param wallet - wallet to use
|
|
36
|
-
* @param params - swap
|
|
37
|
-
* @returns {SwapSubmitted} -
|
|
39
|
+
* @param wallet - The wallet to use for the swap.
|
|
40
|
+
* @param params - The swap parameters.
|
|
41
|
+
* @returns {SwapSubmitted} - The transaction hash, URL of BlockExplorer, and expected wait time.
|
|
38
42
|
*/
|
|
39
|
-
doSwap(
|
|
43
|
+
doSwap({ fromAsset, fromAddress, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, toleranceBps, }: QuoteSwapParams): Promise<TxSubmitted>;
|
|
40
44
|
/**
|
|
41
|
-
*
|
|
42
|
-
* @param
|
|
43
|
-
*
|
|
45
|
+
* Validate if the asset router is allowed to spend the asset amount in name of the address
|
|
46
|
+
* @param {IsApprovedParams} isApprovedParams contains the asset and the amount the router is supposed to spend
|
|
47
|
+
* int name of address
|
|
48
|
+
* @returns {string[]} the reasons the router of the asset is not allowed to spend the amount. If it is empty, the asset router is allowed to spend the amount
|
|
49
|
+
*/
|
|
50
|
+
isRouterApprovedToSpend({ asset, amount, address }: IsApprovedParams): Promise<string[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Wraps the estimate from ThorchainQuery for adding liquidity.
|
|
53
|
+
* @param params - The parameters for estimating adding liquidity.
|
|
54
|
+
* @returns - The estimated liquidity addition object.
|
|
44
55
|
*/
|
|
45
56
|
estimateAddLiquidity(params: AddliquidityPosition): Promise<EstimateAddLP>;
|
|
46
57
|
/**
|
|
47
|
-
* Wraps estimate
|
|
48
|
-
* @param params -
|
|
49
|
-
* @returns -
|
|
58
|
+
* Wraps the estimate from ThorchainQuery for withdrawing liquidity.
|
|
59
|
+
* @param params - The parameters for estimating withdrawing liquidity.
|
|
60
|
+
* @returns - The estimated liquidity withdrawal object.
|
|
50
61
|
*/
|
|
51
62
|
estimateWithdrawLiquidity(params: WithdrawLiquidityPosition): Promise<EstimateWithdrawLP>;
|
|
52
63
|
/**
|
|
53
|
-
*
|
|
54
|
-
* @param wallet -
|
|
55
|
-
* @param params -
|
|
64
|
+
* If there is no existing liquidity position, it is created automatically.
|
|
65
|
+
* @param wallet - Wallet class
|
|
66
|
+
* @param params - Liquidity parameter
|
|
56
67
|
* @returns
|
|
57
68
|
*/
|
|
58
|
-
addLiquidityPosition(
|
|
69
|
+
addLiquidityPosition(params: AddliquidityPosition): Promise<TxSubmitted[]>;
|
|
59
70
|
/**
|
|
60
|
-
*
|
|
61
|
-
* @param params -
|
|
62
|
-
* @
|
|
63
|
-
* @return
|
|
71
|
+
* Withdraws liquidity from a position.
|
|
72
|
+
* @param params - The wallet to perform the transaction.
|
|
73
|
+
* @return - The array of transaction submissions.
|
|
64
74
|
*/
|
|
65
|
-
withdrawLiquidityPosition(
|
|
75
|
+
withdrawLiquidityPosition(params: WithdrawLiquidityPosition): Promise<TxSubmitted[]>;
|
|
66
76
|
/**
|
|
67
|
-
*
|
|
68
|
-
* @param addAssetAmount
|
|
69
|
-
* @returns
|
|
77
|
+
* Estimates adding to a saver.
|
|
78
|
+
* @param addAssetAmount The amount to add to the saver.
|
|
79
|
+
* @returns The estimated addition to the saver object.
|
|
70
80
|
*/
|
|
71
81
|
estimateAddSaver(addAssetAmount: CryptoAmount): Promise<EstimateAddSaver>;
|
|
72
82
|
/**
|
|
73
|
-
*
|
|
74
|
-
* @param withdrawParams
|
|
75
|
-
* @returns
|
|
83
|
+
* Estimates withdrawing from a saver.
|
|
84
|
+
* @param withdrawParams The parameters for withdrawing from the saver.
|
|
85
|
+
* @returns The estimated withdrawal from the saver object.
|
|
76
86
|
*/
|
|
77
87
|
estimateWithdrawSaver(withdrawParams: SaversWithdraw): Promise<EstimateWithdrawSaver>;
|
|
78
88
|
/**
|
|
79
|
-
*
|
|
80
|
-
* @param getsaver
|
|
81
|
-
* @returns
|
|
89
|
+
* Retrieves the position of a saver.
|
|
90
|
+
* @param getsaver The parameters to retrieve the saver position.
|
|
91
|
+
* @returns The saver position object.
|
|
82
92
|
*/
|
|
83
93
|
getSaverPosition(getsaver: getSaver): Promise<SaversPosition>;
|
|
84
94
|
/**
|
|
85
|
-
*
|
|
95
|
+
* Adds assets to a saver.
|
|
86
96
|
* @param wallet - wallet needed to execute tx
|
|
87
|
-
* @param addAssetAmount -
|
|
88
|
-
* @returns - submitted
|
|
97
|
+
* @param addAssetAmount - The amount to add to the saver.
|
|
98
|
+
* @returns - The submitted transaction.
|
|
89
99
|
*/
|
|
90
|
-
addSaver(
|
|
100
|
+
addSaver(addAssetAmount: CryptoAmount): Promise<TxSubmitted>;
|
|
91
101
|
/**
|
|
92
|
-
*
|
|
93
|
-
* @param
|
|
94
|
-
* @
|
|
95
|
-
* @returns
|
|
102
|
+
* Withdraws assets from a saver.
|
|
103
|
+
* @param withdrawParams - The parameters for withdrawing from the saver.
|
|
104
|
+
* @returns The submitted transaction.
|
|
96
105
|
*/
|
|
97
|
-
withdrawSaver(
|
|
106
|
+
withdrawSaver(withdrawParams: SaversWithdraw): Promise<TxSubmitted>;
|
|
98
107
|
/**
|
|
99
|
-
*
|
|
100
|
-
* @param loanOpenParams
|
|
101
|
-
* @returns
|
|
108
|
+
* Retrieves a quote for opening a loan.
|
|
109
|
+
* @param loanOpenParams The parameters for opening the loan.
|
|
110
|
+
* @returns The quote for opening the loan.
|
|
102
111
|
*/
|
|
103
112
|
getLoanQuoteOpen(loanOpenParams: LoanOpenParams): Promise<LoanOpenQuote>;
|
|
104
113
|
/**
|
|
105
|
-
*
|
|
106
|
-
* @param loanCloseParams
|
|
107
|
-
* @returns
|
|
114
|
+
* Retrieves a quote for closing a loan.
|
|
115
|
+
* @param loanCloseParams The parameters for closing the loan.
|
|
116
|
+
* @returns The quote for closing the loan.
|
|
108
117
|
*/
|
|
109
118
|
getLoanQuoteClose(loanCloseParams: LoanCloseParams): Promise<LoanCloseQuote>;
|
|
110
119
|
/**
|
|
111
|
-
*
|
|
112
|
-
* @param
|
|
113
|
-
* @
|
|
114
|
-
* @returns - submitted tx
|
|
120
|
+
* Opens a loan.
|
|
121
|
+
* @param loanOpenParams - The parameters for opening the loan.
|
|
122
|
+
* @returns - The submitted transaction.
|
|
115
123
|
*/
|
|
116
|
-
addLoan(
|
|
124
|
+
addLoan(loanOpenParams: LoanOpenParams): Promise<TxSubmitted>;
|
|
117
125
|
/**
|
|
118
|
-
*
|
|
119
|
-
* @param
|
|
120
|
-
* @
|
|
121
|
-
* @returns
|
|
126
|
+
* Withdraws assets from a loan.
|
|
127
|
+
* @param loanCloseParams - The parameters for withdrawing from the loan.
|
|
128
|
+
* @returns The submitted transaction.
|
|
122
129
|
*/
|
|
123
|
-
withdrawLoan(
|
|
130
|
+
withdrawLoan(loanCloseParams: LoanCloseParams): Promise<TxSubmitted>;
|
|
124
131
|
/**
|
|
125
|
-
*
|
|
126
|
-
* @param address - address
|
|
127
|
-
* @returns
|
|
132
|
+
* Retrieves all Thornames and their associated data owned by an address.
|
|
133
|
+
* @param address - The address to retrieve Thornames for.
|
|
134
|
+
* @returns The Thornames data.
|
|
128
135
|
*/
|
|
129
136
|
getThornamesByAddress(address: string): Promise<import("@xchainjs/xchain-midgard/lib").ReverseTHORNames | undefined>;
|
|
130
137
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { Balance, FeeOption } from '@xchainjs/xchain-client';
|
|
2
2
|
import { LiquidityPool } from '@xchainjs/xchain-thorchain-query';
|
|
3
3
|
import { Address, Asset, BaseAmount, Chain, CryptoAmount } from '@xchainjs/xchain-util';
|
|
4
|
+
/**
|
|
5
|
+
* Represents the balance information for all assets on a particular chain.
|
|
6
|
+
*/
|
|
4
7
|
export type AllBalances = {
|
|
5
8
|
chain: Chain;
|
|
6
9
|
address: string;
|
|
7
10
|
balances: Balance[] | string;
|
|
8
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Represents the parameters for executing a swap transaction.
|
|
14
|
+
*/
|
|
9
15
|
export type ExecuteSwap = {
|
|
10
16
|
input: CryptoAmount;
|
|
11
17
|
destinationAsset: Asset;
|
|
@@ -14,22 +20,34 @@ export type ExecuteSwap = {
|
|
|
14
20
|
feeOption?: FeeOption;
|
|
15
21
|
walletIndex: number;
|
|
16
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Represents a submitted transaction.
|
|
25
|
+
*/
|
|
17
26
|
export type TxSubmitted = {
|
|
18
27
|
hash: string;
|
|
19
28
|
url: string;
|
|
20
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* Represents a liquidity position in a liquidity pool.
|
|
32
|
+
*/
|
|
21
33
|
export type LiquidityPosition = {
|
|
22
34
|
assetPool: LiquidityPool;
|
|
23
35
|
assetAmount: CryptoAmount;
|
|
24
36
|
runeAmount: CryptoAmount;
|
|
25
37
|
impermanentLossProtection: number;
|
|
26
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* Represents the parameters for adding liquidity to a pool.
|
|
41
|
+
*/
|
|
27
42
|
export type AddLiquidity = {
|
|
28
43
|
asset: CryptoAmount;
|
|
29
44
|
rune: CryptoAmount;
|
|
30
45
|
waitTimeSeconds: number;
|
|
31
46
|
assetPool: string;
|
|
32
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Represents the parameters for withdrawing liquidity from a pool.
|
|
50
|
+
*/
|
|
33
51
|
export type WithdrawLiquidity = {
|
|
34
52
|
assetFee: CryptoAmount;
|
|
35
53
|
runeFee: CryptoAmount;
|
|
@@ -39,6 +57,9 @@ export type WithdrawLiquidity = {
|
|
|
39
57
|
assetAddress?: string;
|
|
40
58
|
runeAddress?: string;
|
|
41
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* Represents the parameters for depositing an asset.
|
|
62
|
+
*/
|
|
42
63
|
export type DepositParams = {
|
|
43
64
|
walletIndex?: number;
|
|
44
65
|
asset: Asset;
|
|
@@ -46,16 +67,25 @@ export type DepositParams = {
|
|
|
46
67
|
feeOption: FeeOption;
|
|
47
68
|
memo: string;
|
|
48
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* Represents the parameters for opening a loan.
|
|
72
|
+
*/
|
|
49
73
|
export type LoanOpenParams = {
|
|
50
74
|
memo: string;
|
|
51
75
|
amount: CryptoAmount;
|
|
52
76
|
toAddress: Address;
|
|
53
77
|
};
|
|
78
|
+
/**
|
|
79
|
+
* Represents the parameters for closing a loan.
|
|
80
|
+
*/
|
|
54
81
|
export type LoanCloseParams = {
|
|
55
82
|
memo: string;
|
|
56
83
|
amount: CryptoAmount;
|
|
57
84
|
toAddress: Address;
|
|
58
85
|
};
|
|
86
|
+
/**
|
|
87
|
+
* Represents the parameters for registering a THORName.
|
|
88
|
+
*/
|
|
59
89
|
export type RegisterThornameParams = {
|
|
60
90
|
thorname: string;
|
|
61
91
|
owner?: string;
|
|
@@ -64,6 +94,9 @@ export type RegisterThornameParams = {
|
|
|
64
94
|
preferredAsset?: Asset;
|
|
65
95
|
expirity?: Date;
|
|
66
96
|
};
|
|
97
|
+
/**
|
|
98
|
+
* Represents the parameters for updating a THORName.
|
|
99
|
+
*/
|
|
67
100
|
export type UpdateThornameParams = {
|
|
68
101
|
thorname: string;
|
|
69
102
|
owner?: string;
|
|
@@ -72,3 +105,8 @@ export type UpdateThornameParams = {
|
|
|
72
105
|
preferredAsset?: Asset;
|
|
73
106
|
expirity?: Date;
|
|
74
107
|
};
|
|
108
|
+
export type IsApprovedParams = {
|
|
109
|
+
asset: Asset;
|
|
110
|
+
amount: CryptoAmount;
|
|
111
|
+
address: Address;
|
|
112
|
+
};
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Asset, Chain } from '@xchainjs/xchain-util';
|
|
2
|
+
/**
|
|
3
|
+
* Check if a chain is EVM and supported by the protocol
|
|
4
|
+
* @param {Chain} chain to check
|
|
5
|
+
* @returns true if chain is EVM, otherwise, false
|
|
6
|
+
*/
|
|
7
|
+
export declare const isProtocolEVMChain: (chain: Chain) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Check if asset is ERC20
|
|
10
|
+
* @param {Asset} asset to check
|
|
11
|
+
* @returns true if asset is ERC20, otherwise, false
|
|
12
|
+
*/
|
|
13
|
+
export declare const isProtocolERC20Asset: (asset: Asset) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Check if a chain is EVM and supported by the protocol
|
|
16
|
+
* @param {Chain} chain to check
|
|
17
|
+
* @returns true if chain is EVM, otherwise, false
|
|
18
|
+
*/
|
|
19
|
+
export declare const isProtocolBFTChain: (chain: Chain) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xchainjs/xchain-thorchain-amm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "module that exposes estimating & swappping cryptocurrency assets on thorchain",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"THORChain",
|
|
@@ -36,29 +36,30 @@
|
|
|
36
36
|
"url": "https://github.com/xchainjs/xchainjs-lib/issues"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@xchainjs/xchain-thorchain-query": "0.7.3",
|
|
40
39
|
"@xchainjs/xchain-avax": "0.4.5",
|
|
40
|
+
"@xchainjs/xchain-binance": "5.7.9",
|
|
41
|
+
"@xchainjs/xchain-bitcoin": "0.23.11",
|
|
42
|
+
"@xchainjs/xchain-bitcoincash": "0.17.9",
|
|
41
43
|
"@xchainjs/xchain-bsc": "0.4.6",
|
|
44
|
+
"@xchainjs/xchain-cosmos": "1.0.0",
|
|
45
|
+
"@xchainjs/xchain-doge": "0.7.11",
|
|
42
46
|
"@xchainjs/xchain-ethereum": "0.31.5",
|
|
43
|
-
"@xchainjs/xchain-
|
|
47
|
+
"@xchainjs/xchain-litecoin": "0.13.10",
|
|
48
|
+
"@xchainjs/xchain-thorchain": "1.0.3",
|
|
49
|
+
"@xchainjs/xchain-thorchain-query": "0.7.4",
|
|
50
|
+
"@xchainjs/xchain-util": "^0.13.1",
|
|
51
|
+
"@xchainjs/xchain-wallet": "0.1.6",
|
|
52
|
+
"@xchainjs/xchain-mayachain": "1.0.0"
|
|
44
53
|
},
|
|
45
54
|
"devDependencies": {
|
|
46
55
|
"@binance-chain/javascript-sdk": "^4.2.0",
|
|
47
56
|
"@cosmos-client/core": "0.46.1",
|
|
48
57
|
"@psf/bitcoincashjs-lib": "^4.0.3",
|
|
49
|
-
"@xchainjs/xchain-binance": "^5.7.9",
|
|
50
|
-
"@xchainjs/xchain-bitcoin": "^0.23.10",
|
|
51
|
-
"@xchainjs/xchain-bitcoincash": "^0.17.8",
|
|
52
58
|
"@xchainjs/xchain-client": "^0.16.1",
|
|
53
|
-
"@xchainjs/xchain-cosmos": "^0.21.10",
|
|
54
59
|
"@xchainjs/xchain-crypto": "^0.3.1",
|
|
55
|
-
"@xchainjs/xchain-doge": "^0.7.10",
|
|
56
60
|
"@xchainjs/xchain-thornode": "^0.3.10",
|
|
57
61
|
"@xchainjs/xchain-evm": "^0.4.4",
|
|
58
|
-
"@xchainjs/xchain-litecoin": "^0.13.9",
|
|
59
|
-
"@xchainjs/xchain-mayachain": "^0.2.16",
|
|
60
62
|
"@xchainjs/xchain-midgard": "^0.5.2",
|
|
61
|
-
"@xchainjs/xchain-util": "^0.13.1",
|
|
62
63
|
"@xchainjs/xchain-utxo-providers": "^0.2.11",
|
|
63
64
|
"axios": "^1.3.6",
|
|
64
65
|
"axios-retry": "^3.2.5",
|
|
@@ -77,17 +78,10 @@
|
|
|
77
78
|
"@binance-chain/javascript-sdk": "^4.2.0",
|
|
78
79
|
"@cosmos-client/core": "0.46.1",
|
|
79
80
|
"@psf/bitcoincashjs-lib": "^4.0.3",
|
|
80
|
-
"@xchainjs/xchain-binance": "^5.7.9",
|
|
81
|
-
"@xchainjs/xchain-bitcoin": "^0.23.10",
|
|
82
|
-
"@xchainjs/xchain-bitcoincash": "^0.17.8",
|
|
83
81
|
"@xchainjs/xchain-client": "^0.16.1",
|
|
84
|
-
"@xchainjs/xchain-cosmos": "^0.21.10",
|
|
85
82
|
"@xchainjs/xchain-crypto": "^0.3.1",
|
|
86
|
-
"@xchainjs/xchain-doge": "^0.7.10",
|
|
87
83
|
"@xchainjs/xchain-thornode": "^0.3.10",
|
|
88
84
|
"@xchainjs/xchain-evm": "^0.4.4",
|
|
89
|
-
"@xchainjs/xchain-litecoin": "^0.13.9",
|
|
90
|
-
"@xchainjs/xchain-mayachain": "^0.2.16",
|
|
91
85
|
"@xchainjs/xchain-midgard": "^0.5.2",
|
|
92
86
|
"@xchainjs/xchain-util": "^0.13.1",
|
|
93
87
|
"@xchainjs/xchain-utxo-providers": "^0.2.11",
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { TxHash, XChainClient } from '@xchainjs/xchain-client';
|
|
2
|
-
import { ThorchainCache } from '@xchainjs/xchain-thorchain-query';
|
|
3
|
-
import { Asset, BaseAmount } from '@xchainjs/xchain-util';
|
|
4
|
-
import { ethers } from 'ethers';
|
|
5
|
-
import { DepositParams } from '../types';
|
|
6
|
-
export declare class EvmHelper {
|
|
7
|
-
private evmClient;
|
|
8
|
-
private client;
|
|
9
|
-
private thorchainCache;
|
|
10
|
-
constructor(client: XChainClient, thorchainCache: ThorchainCache);
|
|
11
|
-
/**
|
|
12
|
-
* Transaction to THORChain inbound address.
|
|
13
|
-
*
|
|
14
|
-
* @param {DepositParams} params The transaction options.
|
|
15
|
-
* @returns {TxHash} The transaction hash.
|
|
16
|
-
*
|
|
17
|
-
* @throws {"halted chain"} Thrown if chain is halted.
|
|
18
|
-
* @throws {"halted trading"} Thrown if trading is halted.
|
|
19
|
-
* @throws {"amount is not approved"} Thrown if the amount is not allowed to spend
|
|
20
|
-
* @throws {"router address is not defined"} Thrown if router address is not defined
|
|
21
|
-
*/
|
|
22
|
-
sendDeposit(params: DepositParams): Promise<TxHash>;
|
|
23
|
-
isTCRouterApprovedToSpend(asset: Asset, amount: BaseAmount, walletIndex?: number): Promise<boolean>;
|
|
24
|
-
approveTCRouterToSpend(asset: Asset, amount?: ethers.BigNumber, walletIndex?: number): Promise<ethers.providers.TransactionResponse>;
|
|
25
|
-
}
|
package/lib/utils/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './evm-helper';
|
package/lib/wallet.d.ts
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { AVAXChain } from '@xchainjs/xchain-avax';
|
|
2
|
-
import { BNBChain } from '@xchainjs/xchain-binance';
|
|
3
|
-
import { BTCChain } from '@xchainjs/xchain-bitcoin';
|
|
4
|
-
import { BCHChain } from '@xchainjs/xchain-bitcoincash';
|
|
5
|
-
import { BSCChain } from '@xchainjs/xchain-bsc';
|
|
6
|
-
import { Network, XChainClient, XChainClientParams } from '@xchainjs/xchain-client';
|
|
7
|
-
import { GAIAChain } from '@xchainjs/xchain-cosmos';
|
|
8
|
-
import { DOGEChain } from '@xchainjs/xchain-doge';
|
|
9
|
-
import { ETHChain } from '@xchainjs/xchain-ethereum';
|
|
10
|
-
import { EVMClientParams } from '@xchainjs/xchain-evm';
|
|
11
|
-
import { LTCChain } from '@xchainjs/xchain-litecoin';
|
|
12
|
-
import { MAYAChain, MayachainClientParams } from '@xchainjs/xchain-mayachain';
|
|
13
|
-
import { THORChain, ThorchainClientParams } from '@xchainjs/xchain-thorchain';
|
|
14
|
-
import { ThorchainQuery } from '@xchainjs/xchain-thorchain-query';
|
|
15
|
-
import { Address, CryptoAmount } from '@xchainjs/xchain-util';
|
|
16
|
-
import { UtxoClientParams } from '@xchainjs/xchain-utxo';
|
|
17
|
-
import { AddLiquidity, AllBalances, ExecuteSwap, LoanCloseParams, LoanOpenParams, RegisterThornameParams, TxSubmitted, UpdateThornameParams, WithdrawLiquidity } from './types';
|
|
18
|
-
import { EvmHelper } from './utils/evm-helper';
|
|
19
|
-
export type NodeUrls = Record<Network, string>;
|
|
20
|
-
export type ChainConfigs = Partial<{
|
|
21
|
-
[BTCChain]: Omit<UtxoClientParams, 'phrase' | 'network'>;
|
|
22
|
-
[BCHChain]: Omit<UtxoClientParams, 'phrase' | 'network'>;
|
|
23
|
-
[LTCChain]: Omit<UtxoClientParams, 'phrase' | 'network'>;
|
|
24
|
-
[DOGEChain]: Omit<UtxoClientParams, 'phrase' | 'network'>;
|
|
25
|
-
[ETHChain]: Omit<EVMClientParams, 'phrase' | 'network'>;
|
|
26
|
-
[AVAXChain]: Omit<EVMClientParams, 'phrase' | 'network'>;
|
|
27
|
-
[BSCChain]: Omit<EVMClientParams, 'phrase' | 'network'>;
|
|
28
|
-
[GAIAChain]: Omit<XChainClientParams, 'phrase' | 'network'>;
|
|
29
|
-
[BNBChain]: Omit<XChainClientParams, 'phrase' | 'network'>;
|
|
30
|
-
[THORChain]: Omit<XChainClientParams & ThorchainClientParams, 'phrase' | 'network'>;
|
|
31
|
-
[MAYAChain]: Omit<XChainClientParams & MayachainClientParams, 'phrase' | 'network'>;
|
|
32
|
-
}>;
|
|
33
|
-
/**
|
|
34
|
-
* Wallet Class for managing all xchain-* wallets with a mnemonic seed.
|
|
35
|
-
*/
|
|
36
|
-
export declare class Wallet {
|
|
37
|
-
private thorchainQuery;
|
|
38
|
-
clients: Record<string, XChainClient>;
|
|
39
|
-
evmHelpers: Record<string, EvmHelper>;
|
|
40
|
-
/**
|
|
41
|
-
* Contructor to create a Wallet
|
|
42
|
-
*
|
|
43
|
-
* @param phrase - mnemonic phrase
|
|
44
|
-
* @param thorchainCache - an instance of the ThorchainCache (could be pointing to stagenet,testnet,mainnet)
|
|
45
|
-
* @param chainConfigs - Config by chain
|
|
46
|
-
* @returns Wallet
|
|
47
|
-
*/
|
|
48
|
-
constructor(phrase: string, thorchainQuery: ThorchainQuery, chainConfigs?: ChainConfigs);
|
|
49
|
-
/**
|
|
50
|
-
* Fetch balances for all wallets
|
|
51
|
-
*
|
|
52
|
-
* @returns AllBalances[]
|
|
53
|
-
*/
|
|
54
|
-
getAllBalances(): Promise<AllBalances[]>;
|
|
55
|
-
/**
|
|
56
|
-
* Executes a Swap from THORChainAMM.doSwap()
|
|
57
|
-
*
|
|
58
|
-
* @param swap object with all the required details for a swap.
|
|
59
|
-
* @returns transaction details and explorer url
|
|
60
|
-
* @see ThorchainAMM.doSwap()
|
|
61
|
-
*/
|
|
62
|
-
executeSwap(swap: ExecuteSwap): Promise<TxSubmitted>;
|
|
63
|
-
/** Validate swap object
|
|
64
|
-
*
|
|
65
|
-
* @param swap - swap parameters
|
|
66
|
-
*/
|
|
67
|
-
validateSwap(swap: ExecuteSwap): Promise<string[]>;
|
|
68
|
-
private isThorname;
|
|
69
|
-
/** Function handles all swaps from Rune to asset
|
|
70
|
-
*
|
|
71
|
-
* @param swap - swap parameters
|
|
72
|
-
* @returns - tx submitted object
|
|
73
|
-
*/
|
|
74
|
-
private swapRuneTo;
|
|
75
|
-
/** Function handles all swaps from Non Rune
|
|
76
|
-
*
|
|
77
|
-
* @param swap - swap object
|
|
78
|
-
* @returns - TxSubmitted object
|
|
79
|
-
*/
|
|
80
|
-
private swapNonRune;
|
|
81
|
-
/** Function handles liquidity Add
|
|
82
|
-
* BASED OFF https://dev.thorchain.or›g/thorchain-dev/network/memos
|
|
83
|
-
* @param params input parameters needed to add liquidity
|
|
84
|
-
* @returns transaction details submitted
|
|
85
|
-
*/
|
|
86
|
-
addLiquidity(params: AddLiquidity): Promise<TxSubmitted[]>;
|
|
87
|
-
/** Function handles liquidity Withdraw
|
|
88
|
-
*
|
|
89
|
-
* @param params - parameters required for liquidity position
|
|
90
|
-
* @returns object with tx response, url and wait time in seconds
|
|
91
|
-
*/
|
|
92
|
-
withdrawLiquidity(params: WithdrawLiquidity): Promise<TxSubmitted[]>;
|
|
93
|
-
/**
|
|
94
|
-
*
|
|
95
|
-
* @param assetAmount - amount to add
|
|
96
|
-
* @param memo - memo required
|
|
97
|
-
* @param waitTimeSeconds - expected wait for the transaction to be processed
|
|
98
|
-
* @returns
|
|
99
|
-
*/
|
|
100
|
-
addSavers(assetAmount: CryptoAmount, memo: string, toAddress: Address): Promise<TxSubmitted>;
|
|
101
|
-
/**
|
|
102
|
-
*
|
|
103
|
-
* @param assetAmount - amount to withdraw
|
|
104
|
-
* @param memo - memo required
|
|
105
|
-
* @param waitTimeSeconds - expected wait for the transaction to be processed
|
|
106
|
-
* @returns
|
|
107
|
-
*/
|
|
108
|
-
withdrawSavers(assetAmount: CryptoAmount, memo: string, toAddress: Address): Promise<TxSubmitted>;
|
|
109
|
-
loanOpen(params: LoanOpenParams): Promise<TxSubmitted>;
|
|
110
|
-
loanClose(params: LoanCloseParams): Promise<TxSubmitted>;
|
|
111
|
-
/**
|
|
112
|
-
* Register a THORName with a default expirity of one year. By default chain and chainAddress is getting from wallet instance and is BTC.
|
|
113
|
-
* By default owner is getting from wallet
|
|
114
|
-
* @param thorname - Name to register
|
|
115
|
-
* @param chain - Chain to add alias
|
|
116
|
-
* @param chainAddress - Address to add to chain alias
|
|
117
|
-
* @param owner - Owner address (rune address)
|
|
118
|
-
* @param preferredAsset - referred asset
|
|
119
|
-
* @param expirity - expirity of the domain in MILLISECONDS
|
|
120
|
-
* @param isUpdate - true only if the domain is already register and you want to update its data
|
|
121
|
-
* @returns memo and value of deposit
|
|
122
|
-
*/
|
|
123
|
-
registerThorname(params: RegisterThornameParams): Promise<string>;
|
|
124
|
-
/**
|
|
125
|
-
* Register a THORName with a default expirity of one year. By default chain and chainAddress is getting from wallet instance and is BTC.
|
|
126
|
-
* By default owner is getting from wallet
|
|
127
|
-
* @param thorname - Name to register
|
|
128
|
-
* @param chain - Chain to add alias
|
|
129
|
-
* @param chainAddress - Address to add to chain alias
|
|
130
|
-
* @param owner - Owner address (rune address)
|
|
131
|
-
* @param preferredAsset - referred asset
|
|
132
|
-
* @param expirity - expirity of the domain in MILLISECONDS
|
|
133
|
-
* @returns memo and value of deposit
|
|
134
|
-
*/
|
|
135
|
-
updateThorname(params: UpdateThornameParams): Promise<string>;
|
|
136
|
-
/** Function handles liquidity add for all non rune assets
|
|
137
|
-
*
|
|
138
|
-
* @param params - parameters for add liquidity
|
|
139
|
-
* @param constructedMemo - memo needed for thorchain
|
|
140
|
-
* @param waitTimeSeconds - wait time for the tx to be confirmed
|
|
141
|
-
* @param assetClient - passing XchainClient
|
|
142
|
-
* @param inboundAsgard - inbound Asgard address for the LP
|
|
143
|
-
* @returns - tx object
|
|
144
|
-
*/
|
|
145
|
-
private addAssetLP;
|
|
146
|
-
/** Function handles liquidity Withdraw for Non rune assets
|
|
147
|
-
*
|
|
148
|
-
* @param params - parameters for withdraw liquidity
|
|
149
|
-
* @param constructedMemo - memo needed for thorchain execution
|
|
150
|
-
* @param assetClient - asset client to call transfer
|
|
151
|
-
* @param waitTimeSeconds - return back estimated wait
|
|
152
|
-
* @param inboundAsgard - destination address
|
|
153
|
-
* @returns - tx object
|
|
154
|
-
*/
|
|
155
|
-
private withdrawAssetLP;
|
|
156
|
-
/** Function handles liquidity Add for Rune only
|
|
157
|
-
*
|
|
158
|
-
* @param params - deposit parameters
|
|
159
|
-
* @param memo - memo needed to withdraw lp
|
|
160
|
-
* @returns - tx object
|
|
161
|
-
*/
|
|
162
|
-
private addRuneLP;
|
|
163
|
-
/** Function handles liquidity Withdraw for Rune only
|
|
164
|
-
*
|
|
165
|
-
* @param params - withdraw parameters
|
|
166
|
-
* @param memo - memo needed to withdraw lp
|
|
167
|
-
* @returns - tx object
|
|
168
|
-
*/
|
|
169
|
-
private withdrawRuneLP;
|
|
170
|
-
private isERC20Asset;
|
|
171
|
-
private isEVMChain;
|
|
172
|
-
private isUTXOChain;
|
|
173
|
-
}
|