@xchainjs/xchain-thorchain-amm 0.1.0-alpha2 → 0.1.0-beta

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
@@ -4,7 +4,6 @@
4
4
 
5
5
  Thorchain AMM module
6
6
 
7
-
8
7
  ## Installation
9
8
 
10
9
  ```
@@ -13,94 +12,59 @@ yarn add @xchainjs/xchain-thorchain-amm
13
12
 
14
13
  Following peer dependencies have to be installed into your project. These are not included in `@xchainjs/xchain-thorchain-amm`.
15
14
 
15
+ ```bash
16
+ "dependencies": {
17
+ "@binance-chain/javascript-sdk": "^4.2.0",
18
+ "@cosmos-client/core": "^0.45.1",
19
+ "@psf/bitcoincashjs-lib": "^4.0.2",
20
+ "@terra-money/terra.js": "^3.1.4",
21
+ "@xchainjs/xchain-binance": "^5.5.0",
22
+ "@xchainjs/xchain-bitcoin": "^0.19.0",
23
+ "@xchainjs/xchain-bitcoincash": "^0.14.0",
24
+ "@xchainjs/xchain-client": "^0.12.0",
25
+ "@xchainjs/xchain-cosmos": "^0.19.0",
26
+ "@xchainjs/xchain-crypto": "^0.2.6",
27
+ "@xchainjs/xchain-doge": "^0.3.0",
28
+ "@xchainjs/xchain-ethereum": "^0.26.0",
29
+ "@xchainjs/xchain-litecoin": "^0.9.0",
30
+ "@xchainjs/xchain-midgard": "^0.1.0-alpha2",
31
+ "@xchainjs/xchain-terra": "^0.2.0",
32
+ "@xchainjs/xchain-thorchain": "^0.25.3",
33
+ "@xchainjs/xchain-thornode": "^0.1.0-alpha3",
34
+ "@xchainjs/xchain-util": "^0.8.0",
35
+ "axios": "^0.27.2",
36
+ "axios-retry": "^3.3.1",
37
+ "bchaddrjs": "^0.5.2",
38
+ "bech32-buffer": "^0.2.0",
39
+ "bitcoinjs-lib": "^6.0.1",
40
+ "dotenv": "^16.0.0",
41
+ "ethers": "^5.6.2"
42
+ }
43
+
16
44
  ```
17
- yarn add @xchainjs/xchain-client @xchainjs/xchain-crypto @xchainjs/xchain-util @xchainjs/xchain-cosmos axios @cosmos-client/core bech32-buffer
18
- ```
45
+ ## Examples
19
46
 
20
- ## Usage
21
47
 
22
- ### Estimating a swap from BTC -> BUSD
23
48
 
24
- ```typescript
25
- import { Network } from '@xchainjs/xchain-client'
26
- import { AssetBTC, assetAmount, assetFromString, assetToBase } from '@xchainjs/xchain-util'
27
- import BigNumber from 'bignumber.js'
49
+ ## Documentation
28
50
 
29
- import { CryptoAmount, EstimateSwapParams, Midgard, SwapEstimate, ThorchainAMM } from '@xchainjs/xchain-thorchain-amm'
51
+ [xchain thorchain-amm](http://docs.xchainjs.org/xchain-thorchain-amm/)
52
+ [How thorchain-amm works](http://docs.xchainjs.org/xchain-thorchain-amm/how-it-works.html)\
53
+ [How to use thorchain-amm](http://docs.xchainjs.org/xchain-thorchain-amm/how-to-use.html)
30
54
 
31
- const BUSD = assetFromString('BNB.BUSD-BD1')
32
- if (!BUSD) throw Error('bad asset')
55
+ ##
33
56
 
34
- function print(estimate: SwapEstimate, input: CryptoAmount) {
35
- const expanded = {
36
- input: input.formatedAssetString(),
37
- totalFees: {
38
- inboundFee: estimate.totalFees.inboundFee.formatedAssetString(),
39
- swapFee: estimate.totalFees.swapFee.formatedAssetString(),
40
- outboundFee: estimate.totalFees.outboundFee.formatedAssetString(),
41
- affiliateFee: estimate.totalFees.affiliateFee.formatedAssetString(),
42
- },
43
- slipPercentage: estimate.slipPercentage.toFixed(),
44
- netOutput: estimate.netOutput.formatedAssetString(),
45
- waitTimeSeconds: estimate.waitTimeSeconds.toFixed(),
46
- canSwap: estimate.canSwap,
47
- errors: estimate.errors,
48
- }
49
- console.log(expanded)
50
- }
51
- try {
52
- const midgard = new Midgard(Network.Mainnet) //defaults to mainnet
53
- const thorchainAmm = new ThorchainAMM(midgard)
54
- const swapParams: EstimateSwapParams = {
55
- input: new CryptoAmount(assetToBase(assetAmount('1')), AssetBTC),
56
- destinationAsset: BUSD,
57
- // affiliateFeePercent: 0.003, //optional
58
- slipLimit: new BigNumber('0.03'), //optional
59
- }
60
- const estimate = await thorchainAmm.estimateSwap(swapParams)
61
- print(estimate, swapParams.input)
57
+ tsconfig compiler options
62
58
 
63
- // convert fees (by defualt returned in RUNE) to a different asset (BUSD)
64
- const estimateInBusd = await thorchainAmm.getFeesIn(estimate.totalFees, BUSD)
65
- estimate.totalFees = estimateInBusd
66
- print(estimate, swapParams.input)
67
- } catch (e) {
68
- console.error(e)
69
- }
70
-
71
- ```
72
-
73
- ## output
74
-
75
- ```
76
- ===Estimate with fees in Rune===
77
- {
78
- input: '₿ 1',
79
- totalFees: {
80
- inboundFee: 'ᚱ 0.02165694',
81
- swapFee: 'ᚱ 69.57707207',
82
- outboundFee: 'ᚱ 0.03235451',
83
- affiliateFee: 'ᚱ 0'
84
- },
85
- slipPercentage: '0.00299630164689824336',
86
- netOutput: '$ 23,151.33630401',
87
- waitTimeSeconds: '1116',
88
- canSwap: true,
89
- errors: undefined
90
- }
91
- ===Estimate with fees in BUSD===
59
+ ```ts
92
60
  {
93
- input: '₿ 1',
94
- totalFees: {
95
- inboundFee: '$ 0.05822673',
96
- swapFee: '$ 187.06454402',
97
- outboundFee: '$ 0.08698816',
98
- affiliateFee: '$ 0'
99
- },
100
- slipPercentage: '0.00299630164689824336',
101
- netOutput: '$ 23,151.33630401',
102
- waitTimeSeconds: '1116',
103
- canSwap: true,
104
- errors: undefined
61
+ "compilerOptions": {
62
+ "module":"commonjs",
63
+ "target": "es5",
64
+ "noEmitOnError": true,
65
+ "resolveJsonModule": true,
66
+ "esModuleInterop": true,
67
+ "lib": ["es6", "dom", "es2016", "es2017"]
68
+ }
105
69
  }
106
- ```
70
+ ```
@@ -1,4 +1,4 @@
1
- import { Chain } from '@xchainjs/xchain-util/lib';
1
+ import { Chain } from '@xchainjs/xchain-util';
2
2
  import { ChainAttributes } from './types';
3
3
  declare const DefaultChainAttributes: Record<Chain, ChainAttributes>;
4
4
  export { DefaultChainAttributes };
@@ -1,5 +1,6 @@
1
1
  export * from './wallet';
2
2
  export * from './thorchain-amm';
3
+ export * from './thorchain-cache';
3
4
  export * from './liquidity-pool';
4
5
  export * from './types';
5
6
  export * from './crypto-amount';