@xchainjs/xchain-thorchain-amm 2.0.0 → 2.0.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 +89 -84
- package/package.json +16 -16
package/README.md
CHANGED
|
@@ -1,83 +1,110 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1 align="center">THORChain AMM</h1>
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
<p align="center">
|
|
5
|
+
<a href='https://www.npmjs.com/package/@xchainjs/xchain-thorchain-amm' target='_blank'>
|
|
6
|
+
<img alt="NPM Version" src="https://img.shields.io/npm/v/%40xchainjs%2Fxchain-thorchain-amm" />
|
|
7
|
+
</a>
|
|
8
|
+
<a href='https://www.npmjs.com/package/@xchainjs/xchain-thorchain-amm' target='_blank'>
|
|
9
|
+
<img alt="NPM Downloads" src="https://img.shields.io/npm/d18m/%40xchainjs%2Fxchain-thorchain-amm" />
|
|
10
|
+
</a>
|
|
11
|
+
</p>
|
|
12
|
+
</div>
|
|
4
13
|
|
|
5
|
-
|
|
14
|
+
<br />
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
THORChain AMM is a module that allows users and developers to interact with the THORChain protocol without having to worry about the underlining particularities of the protocol.
|
|
6
18
|
|
|
7
19
|
## Installation
|
|
8
20
|
|
|
9
|
-
```
|
|
21
|
+
```sh
|
|
10
22
|
yarn add @xchainjs/xchain-thorchain-amm
|
|
11
23
|
```
|
|
12
24
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"@binance-chain/javascript-sdk": "^4.2.0",
|
|
18
|
-
"@cosmos-client/core": "0.46.1",
|
|
19
|
-
"@psf/bitcoincashjs-lib": "^4.0.2",
|
|
20
|
-
"@xchainjs/xchain-binance": "^5.6.6",
|
|
21
|
-
"@xchainjs/xchain-bitcoin": "^0.20.7",
|
|
22
|
-
"@xchainjs/xchain-bitcoincash": "^0.15.6",
|
|
23
|
-
"@xchainjs/xchain-client": "^0.13.5",
|
|
24
|
-
"@xchainjs/xchain-cosmos": "^0.20.6",
|
|
25
|
-
"@xchainjs/xchain-crypto": "^0.2.6",
|
|
26
|
-
"@xchainjs/xchain-doge": "^0.5.6",
|
|
27
|
-
"@xchainjs/xchain-ethereum": "^0.27.6",
|
|
28
|
-
"@xchainjs/xchain-evm": "^0.1.3",
|
|
29
|
-
"@xchainjs/xchain-avax": "^0.1.3",
|
|
30
|
-
"@xchainjs/xchain-litecoin": "^0.10.8",
|
|
31
|
-
"@xchainjs/xchain-midgard": "0.4.1",
|
|
32
|
-
"@xchainjs/xchain-thorchain": "^0.27.7",
|
|
33
|
-
"@xchainjs/xchain-thorchain-query": "^0.1.12",
|
|
34
|
-
"@xchainjs/xchain-thornode": "^0.1.5",
|
|
35
|
-
"@xchainjs/xchain-util": "^0.12.0",
|
|
36
|
-
"axios": "^0.25.0",
|
|
37
|
-
"axios-retry": "^3.2.5",
|
|
38
|
-
"bchaddrjs": "^0.5.2",
|
|
39
|
-
"bech32": "^2.0.0",
|
|
40
|
-
"bech32-buffer": "^0.2.0",
|
|
41
|
-
"bignumber.js": "^9.0.0",
|
|
42
|
-
"bitcoinjs-lib": "^5.2.0",
|
|
43
|
-
"coininfo": "^5.1.0",
|
|
44
|
-
"coinselect": "^3.1.12",
|
|
45
|
-
"ethers": "^5.6.6",
|
|
46
|
-
"wif": "^2.0.6"
|
|
47
|
-
}
|
|
25
|
+
or
|
|
48
26
|
|
|
27
|
+
```sh
|
|
28
|
+
npm install @xchainjs/xchain-thorchain-amm
|
|
49
29
|
```
|
|
50
30
|
|
|
51
|
-
##
|
|
52
|
-
|
|
53
|
-
Do Swap: https://replit.com/@thorchain/doSwap-Single \
|
|
54
|
-
Add Liquidity: https://replit.com/@thorchain/addLiquidity \
|
|
55
|
-
Withdraw liquidity: https://replit.com/@thorchain/removeLiquidity \
|
|
56
|
-
Add Savers & withdraw Savers: https://replit.com/@thorchain/saversTs#index.ts
|
|
31
|
+
## Initialization
|
|
57
32
|
|
|
58
|
-
|
|
33
|
+
Using Thorchain AMM, you can initialize the main class of the module in consultation mode if you do not provide any parameters, this means you could retrieve information from the protocol, but you will not be able to make actions the protocol needs you to sign.
|
|
59
34
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
[How to use thorchain-amm](http://docs.xchainjs.org/xchain-thorchain-amm/how-to-use.html)
|
|
35
|
+
```ts
|
|
36
|
+
import { ThorchainAMM } from '@xchainjs/xchain-thorchain-amm'
|
|
63
37
|
|
|
64
|
-
|
|
38
|
+
const thorchainAmm = new ThorchainAMM()
|
|
39
|
+
```
|
|
65
40
|
|
|
66
|
-
|
|
41
|
+
Otherwise, if you want to be able make actions the protocol needs you to sign, you will need to initialize the main class of the protocol as follows
|
|
67
42
|
|
|
68
43
|
```ts
|
|
69
|
-
{
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
44
|
+
import { ThorchainAMM } from '@xchainjs/xchain-thorchain-amm'
|
|
45
|
+
import { ThorchainQuery } from '@xchainjs/xchain-thorchain-query'
|
|
46
|
+
import { Wallet } from '@xchainjs/xchain-wallet'
|
|
47
|
+
|
|
48
|
+
const thorChainQuery = new ThorchainQuery()
|
|
49
|
+
const wallet = new Wallet({
|
|
50
|
+
// Your XChainJS clients
|
|
51
|
+
})
|
|
52
|
+
const thorchainAmm = new ThorchainAMM(thorChainQuery, wallet)
|
|
79
53
|
```
|
|
80
54
|
|
|
55
|
+
|
|
56
|
+
## Features
|
|
57
|
+
|
|
58
|
+
Using THORChain AMM package, you could easily implement the following features
|
|
59
|
+
|
|
60
|
+
### Swaps
|
|
61
|
+
|
|
62
|
+
- Estimate swaps
|
|
63
|
+
- Do swaps, streaming swaps and trade asset swaps
|
|
64
|
+
- Approve THORChain router to be able to do ERC-20 swaps
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
### Liquidity pools
|
|
68
|
+
|
|
69
|
+
- Add liquidity to pools, symmetrical and asymmetrical
|
|
70
|
+
- Withdraw liquidity from pools
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
### Rune pool
|
|
74
|
+
|
|
75
|
+
- Deposit Rune to Rune pool
|
|
76
|
+
- Withdraw Rune from Rune pool
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
### Savers
|
|
80
|
+
|
|
81
|
+
- Add a position in a THORChain savers vault
|
|
82
|
+
- Withdraw a position from a THORChain savers vault
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
### Trade assets
|
|
86
|
+
|
|
87
|
+
- Deposit L1 assets into the THORChain network to mint trade assets to receive accredited shares
|
|
88
|
+
- Swap trade assets with RUNE or another trade asset
|
|
89
|
+
- Withdraw trade asset balance
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
### THORNames
|
|
93
|
+
|
|
94
|
+
- Get THORNames details
|
|
95
|
+
- Get THORNames by owner
|
|
96
|
+
- Register and update THORNames
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
## Examples
|
|
100
|
+
|
|
101
|
+
You can find examples using the THORChain AMM package in the [thorchain-amm](https://github.com/xchainjs/xchainjs-lib/tree/master/examples/thorchain-amm) examples folder.
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
## Documentation
|
|
105
|
+
|
|
106
|
+
More information about how to use the Thorchain AMM package can be found on [documentation](https://xchainjs.gitbook.io/xchainjs/protocols/thorchain/xchain-thorchain-amm)
|
|
107
|
+
|
|
81
108
|
### Setting Headers for Nine Realms endpoints
|
|
82
109
|
|
|
83
110
|
If you plan on using the publically accessible endpoints provided by Nine Realms(listed below), ensure that you add a valid 'x-client-id' to all requests
|
|
@@ -86,26 +113,6 @@ If you plan on using the publically accessible endpoints provided by Nine Realms
|
|
|
86
113
|
- https://haskoin.ninerealms.com (BTC/BCH/LTC)
|
|
87
114
|
- https://thornode.ninerealms.com
|
|
88
115
|
|
|
89
|
-
### Setting environment variables
|
|
90
|
-
|
|
91
|
-
```sh
|
|
92
|
-
SNOWTRACE_API_KEY={YOUR_SNOWTRACE_API_KEY}
|
|
93
|
-
COVALENT_API_KEY={YOUR_COVALENT_API_KEY}
|
|
94
|
-
BLOCKCYPHER_API_KEY={YOUR_BLOCKCYPHER_API_KEY}
|
|
95
|
-
SOCHAIN_API_KEY={YOUR_SOCHAIN_API_KEY}
|
|
96
|
-
BSCSCAN_API_KEY={YOUR_BSCSCAN_API_KEY}
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
//Default config can access.
|
|
100
|
-
|
|
101
|
-
```sh
|
|
102
|
-
process.env.SNOWTRACE_API_KEY
|
|
103
|
-
process.env.COVALENT_API_KEY
|
|
104
|
-
process.env.BLOCKCYPHER_API_KEY
|
|
105
|
-
process.env.SOCHAIN_API_KEY
|
|
106
|
-
process.env.BSCSCAN_API_KEY
|
|
107
|
-
```
|
|
108
|
-
|
|
109
116
|
Example
|
|
110
117
|
|
|
111
118
|
```typescript
|
|
@@ -115,6 +122,4 @@ import { register9Rheader } from '@xchainjs/xchain-util'
|
|
|
115
122
|
|
|
116
123
|
register9Rheader(axios)
|
|
117
124
|
register9Rheader(cosmosclient.config.globalAxios)
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
For a complete example please see this [test](https://github.com/xchainjs/xchainjs-lib/blob/master/packages/xchain-thorchain-amm/__e2e__/wallet.e2e.ts)
|
|
125
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xchainjs/xchain-thorchain-amm",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "module that exposes estimating & swappping cryptocurrency assets on thorchain",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"THORChain",
|
|
@@ -36,26 +36,26 @@
|
|
|
36
36
|
"url": "https://github.com/xchainjs/xchainjs-lib/issues"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@xchainjs/xchain-avax": "1.0.
|
|
40
|
-
"@xchainjs/xchain-binance": "6.0.
|
|
41
|
-
"@xchainjs/xchain-bitcoin": "1.0.
|
|
42
|
-
"@xchainjs/xchain-bitcoincash": "1.0.
|
|
43
|
-
"@xchainjs/xchain-bsc": "1.0.
|
|
44
|
-
"@xchainjs/xchain-client": "1.0.
|
|
45
|
-
"@xchainjs/xchain-cosmos": "2.0.
|
|
46
|
-
"@xchainjs/xchain-doge": "1.0.
|
|
47
|
-
"@xchainjs/xchain-ethereum": "1.0.
|
|
48
|
-
"@xchainjs/xchain-evm": "1.0.
|
|
49
|
-
"@xchainjs/xchain-litecoin": "1.0.
|
|
50
|
-
"@xchainjs/xchain-thorchain": "2.0.
|
|
51
|
-
"@xchainjs/xchain-thorchain-query": "1.0.
|
|
39
|
+
"@xchainjs/xchain-avax": "1.0.2",
|
|
40
|
+
"@xchainjs/xchain-binance": "6.0.1",
|
|
41
|
+
"@xchainjs/xchain-bitcoin": "1.0.1",
|
|
42
|
+
"@xchainjs/xchain-bitcoincash": "1.0.1",
|
|
43
|
+
"@xchainjs/xchain-bsc": "1.0.2",
|
|
44
|
+
"@xchainjs/xchain-client": "1.0.1",
|
|
45
|
+
"@xchainjs/xchain-cosmos": "2.0.1",
|
|
46
|
+
"@xchainjs/xchain-doge": "1.0.1",
|
|
47
|
+
"@xchainjs/xchain-ethereum": "1.0.2",
|
|
48
|
+
"@xchainjs/xchain-evm": "1.0.2",
|
|
49
|
+
"@xchainjs/xchain-litecoin": "1.0.1",
|
|
50
|
+
"@xchainjs/xchain-thorchain": "2.0.1",
|
|
51
|
+
"@xchainjs/xchain-thorchain-query": "1.0.1",
|
|
52
52
|
"@xchainjs/xchain-util": "1.0.0",
|
|
53
|
-
"@xchainjs/xchain-wallet": "1.0.
|
|
53
|
+
"@xchainjs/xchain-wallet": "1.0.2",
|
|
54
54
|
"ethers": "5.7.2"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@ledgerhq/hw-transport-node-hid": "6.28.6",
|
|
58
|
-
"axios": "1.
|
|
58
|
+
"axios": "1.7.4",
|
|
59
59
|
"axios-mock-adapter": "1.20.0"
|
|
60
60
|
},
|
|
61
61
|
"publishConfig": {
|