@xchainjs/xchain-thorchain-amm 1.1.0 → 1.1.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/lib/index.esm.js CHANGED
@@ -12745,7 +12745,7 @@ class ThorchainAMM {
12745
12745
 
12746
12746
  * @returns The estimated swap details.
12747
12747
  */
12748
- estimateSwap({ fromAddress, fromAsset, amount, destinationAsset, destinationAddress, affiliateAddress = '', affiliateBps = 0, toleranceBps, }) {
12748
+ estimateSwap({ fromAddress, fromAsset, amount, destinationAsset, destinationAddress, affiliateAddress = '', affiliateBps = 0, toleranceBps, streamingInterval, streamingQuantity, }) {
12749
12749
  return __awaiter$6(this, void 0, void 0, function* () {
12750
12750
  const errors = yield this.validateSwap({
12751
12751
  fromAddress,
@@ -12762,6 +12762,8 @@ class ThorchainAMM {
12762
12762
  affiliateAddress,
12763
12763
  affiliateBps,
12764
12764
  toleranceBps,
12765
+ streamingInterval,
12766
+ streamingQuantity,
12765
12767
  });
12766
12768
  // Add any validation errors to the estimate
12767
12769
  estimate.txEstimate.errors.push(...errors);
@@ -12774,7 +12776,7 @@ class ThorchainAMM {
12774
12776
  * @param {QuoteSwapParams} quoteSwapParams Swap params
12775
12777
  * @returns {string[]} the reasons the swap can not be done. If it is empty there are no reason to avoid the swap
12776
12778
  */
12777
- validateSwap({ fromAsset, fromAddress, destinationAsset, destinationAddress, amount, affiliateAddress, affiliateBps, }) {
12779
+ validateSwap({ fromAsset, fromAddress, destinationAsset, destinationAddress, amount, affiliateAddress, affiliateBps, streamingInterval, streamingQuantity, }) {
12778
12780
  return __awaiter$6(this, void 0, void 0, function* () {
12779
12781
  const errors = [];
12780
12782
  if (destinationAddress &&
@@ -12790,6 +12792,12 @@ class ThorchainAMM {
12790
12792
  if (affiliateBps && (affiliateBps < 0 || affiliateBps > 10000)) {
12791
12793
  errors.push(`affiliateBps ${affiliateBps} out of range [0 - 10000]`);
12792
12794
  }
12795
+ if (streamingInterval && streamingInterval < 0) {
12796
+ errors.push(`streamingInterval ${streamingInterval} can not be lower than zero`);
12797
+ }
12798
+ if (streamingQuantity && streamingQuantity < 0) {
12799
+ errors.push(`streamingQuantity ${streamingQuantity} can not be lower than zero`);
12800
+ }
12793
12801
  if (isProtocolERC20Asset(fromAsset) && fromAddress) {
12794
12802
  const approveErrors = yield this.isRouterApprovedToSpend({
12795
12803
  asset: fromAsset,
@@ -12808,7 +12816,7 @@ class ThorchainAMM {
12808
12816
  * @param params - The swap parameters.
12809
12817
  * @returns {SwapSubmitted} - The transaction hash, URL of BlockExplorer, and expected wait time.
12810
12818
  */
12811
- doSwap({ fromAsset, fromAddress, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, toleranceBps, }) {
12819
+ doSwap({ fromAsset, fromAddress, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, toleranceBps, streamingInterval, streamingQuantity, }) {
12812
12820
  return __awaiter$6(this, void 0, void 0, function* () {
12813
12821
  // Retrieve swap details from ThorchainQuery to ensure validity
12814
12822
  const txDetails = yield this.thorchainQuery.quoteSwap({
@@ -12820,6 +12828,8 @@ class ThorchainAMM {
12820
12828
  affiliateAddress,
12821
12829
  affiliateBps,
12822
12830
  toleranceBps,
12831
+ streamingInterval,
12832
+ streamingQuantity,
12823
12833
  });
12824
12834
  if (!txDetails.txEstimate.canSwap) {
12825
12835
  throw Error(txDetails.txEstimate.errors.join('\n'));
package/lib/index.js CHANGED
@@ -12749,7 +12749,7 @@ class ThorchainAMM {
12749
12749
 
12750
12750
  * @returns The estimated swap details.
12751
12751
  */
12752
- estimateSwap({ fromAddress, fromAsset, amount, destinationAsset, destinationAddress, affiliateAddress = '', affiliateBps = 0, toleranceBps, }) {
12752
+ estimateSwap({ fromAddress, fromAsset, amount, destinationAsset, destinationAddress, affiliateAddress = '', affiliateBps = 0, toleranceBps, streamingInterval, streamingQuantity, }) {
12753
12753
  return __awaiter$6(this, void 0, void 0, function* () {
12754
12754
  const errors = yield this.validateSwap({
12755
12755
  fromAddress,
@@ -12766,6 +12766,8 @@ class ThorchainAMM {
12766
12766
  affiliateAddress,
12767
12767
  affiliateBps,
12768
12768
  toleranceBps,
12769
+ streamingInterval,
12770
+ streamingQuantity,
12769
12771
  });
12770
12772
  // Add any validation errors to the estimate
12771
12773
  estimate.txEstimate.errors.push(...errors);
@@ -12778,7 +12780,7 @@ class ThorchainAMM {
12778
12780
  * @param {QuoteSwapParams} quoteSwapParams Swap params
12779
12781
  * @returns {string[]} the reasons the swap can not be done. If it is empty there are no reason to avoid the swap
12780
12782
  */
12781
- validateSwap({ fromAsset, fromAddress, destinationAsset, destinationAddress, amount, affiliateAddress, affiliateBps, }) {
12783
+ validateSwap({ fromAsset, fromAddress, destinationAsset, destinationAddress, amount, affiliateAddress, affiliateBps, streamingInterval, streamingQuantity, }) {
12782
12784
  return __awaiter$6(this, void 0, void 0, function* () {
12783
12785
  const errors = [];
12784
12786
  if (destinationAddress &&
@@ -12794,6 +12796,12 @@ class ThorchainAMM {
12794
12796
  if (affiliateBps && (affiliateBps < 0 || affiliateBps > 10000)) {
12795
12797
  errors.push(`affiliateBps ${affiliateBps} out of range [0 - 10000]`);
12796
12798
  }
12799
+ if (streamingInterval && streamingInterval < 0) {
12800
+ errors.push(`streamingInterval ${streamingInterval} can not be lower than zero`);
12801
+ }
12802
+ if (streamingQuantity && streamingQuantity < 0) {
12803
+ errors.push(`streamingQuantity ${streamingQuantity} can not be lower than zero`);
12804
+ }
12797
12805
  if (isProtocolERC20Asset(fromAsset) && fromAddress) {
12798
12806
  const approveErrors = yield this.isRouterApprovedToSpend({
12799
12807
  asset: fromAsset,
@@ -12812,7 +12820,7 @@ class ThorchainAMM {
12812
12820
  * @param params - The swap parameters.
12813
12821
  * @returns {SwapSubmitted} - The transaction hash, URL of BlockExplorer, and expected wait time.
12814
12822
  */
12815
- doSwap({ fromAsset, fromAddress, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, toleranceBps, }) {
12823
+ doSwap({ fromAsset, fromAddress, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, toleranceBps, streamingInterval, streamingQuantity, }) {
12816
12824
  return __awaiter$6(this, void 0, void 0, function* () {
12817
12825
  // Retrieve swap details from ThorchainQuery to ensure validity
12818
12826
  const txDetails = yield this.thorchainQuery.quoteSwap({
@@ -12824,6 +12832,8 @@ class ThorchainAMM {
12824
12832
  affiliateAddress,
12825
12833
  affiliateBps,
12826
12834
  toleranceBps,
12835
+ streamingInterval,
12836
+ streamingQuantity,
12827
12837
  });
12828
12838
  if (!txDetails.txEstimate.canSwap) {
12829
12839
  throw Error(txDetails.txEstimate.errors.join('\n'));
@@ -26,13 +26,13 @@ export declare class ThorchainAMM {
26
26
 
27
27
  * @returns The estimated swap details.
28
28
  */
29
- estimateSwap({ fromAddress, fromAsset, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, toleranceBps, }: QuoteSwapParams): Promise<TxDetails>;
29
+ estimateSwap({ fromAddress, fromAsset, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, toleranceBps, streamingInterval, streamingQuantity, }: QuoteSwapParams): Promise<TxDetails>;
30
30
  /**
31
31
  * Validate swap params
32
32
  * @param {QuoteSwapParams} quoteSwapParams Swap params
33
33
  * @returns {string[]} the reasons the swap can not be done. If it is empty there are no reason to avoid the swap
34
34
  */
35
- validateSwap({ fromAsset, fromAddress, destinationAsset, destinationAddress, amount, affiliateAddress, affiliateBps, }: QuoteSwapParams): Promise<string[]>;
35
+ validateSwap({ fromAsset, fromAddress, destinationAsset, destinationAddress, amount, affiliateAddress, affiliateBps, streamingInterval, streamingQuantity, }: QuoteSwapParams): Promise<string[]>;
36
36
  /**
37
37
  * Conducts a swap with the given inputs. This method should be called after estimateSwap() to ensure the swap is valid.
38
38
  *
@@ -40,7 +40,7 @@ export declare class ThorchainAMM {
40
40
  * @param params - The swap parameters.
41
41
  * @returns {SwapSubmitted} - The transaction hash, URL of BlockExplorer, and expected wait time.
42
42
  */
43
- doSwap({ fromAsset, fromAddress, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, toleranceBps, }: QuoteSwapParams): Promise<TxSubmitted>;
43
+ doSwap({ fromAsset, fromAddress, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, toleranceBps, streamingInterval, streamingQuantity, }: QuoteSwapParams): Promise<TxSubmitted>;
44
44
  /**
45
45
  * Approve the Thorchain router to spend a certain amount in the asset chain.
46
46
  * @param {ApproveParams} approveParams Parameters for approving the router to spend
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-thorchain-amm",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "module that exposes estimating & swappping cryptocurrency assets on thorchain",
5
5
  "keywords": [
6
6
  "THORChain",
@@ -29,7 +29,6 @@
29
29
  "test": "jest",
30
30
  "e2e": "jest --config jest.config.e2e.js",
31
31
  "lint": "eslint \"{src,__tests__}/**/*.ts\" --fix --max-warnings 0",
32
- "prepublishOnly": "yarn build",
33
32
  "postversion": "git push --follow-tags"
34
33
  },
35
34
  "bugs": {
@@ -47,7 +46,7 @@
47
46
  "@xchainjs/xchain-evm": "0.4.5",
48
47
  "@xchainjs/xchain-litecoin": "0.13.11",
49
48
  "@xchainjs/xchain-thorchain": "1.0.4",
50
- "@xchainjs/xchain-thorchain-query": "0.7.7",
49
+ "@xchainjs/xchain-thorchain-query": "0.7.8",
51
50
  "@xchainjs/xchain-util": "^0.13.3",
52
51
  "@xchainjs/xchain-wallet": "0.1.8",
53
52
  "@xchainjs/xchain-mayachain": "1.0.1"
@@ -58,8 +57,8 @@
58
57
  "@psf/bitcoincashjs-lib": "^4.0.3",
59
58
  "@xchainjs/xchain-client": "^0.16.2",
60
59
  "@xchainjs/xchain-crypto": "^0.3.1",
61
- "@xchainjs/xchain-thornode": "^0.3.11",
62
- "@xchainjs/xchain-midgard": "^0.5.2",
60
+ "@xchainjs/xchain-thornode": "^0.3.12",
61
+ "@xchainjs/xchain-midgard": "^0.5.4",
63
62
  "@xchainjs/xchain-utxo-providers": "^0.2.12",
64
63
  "axios": "^1.3.6",
65
64
  "axios-retry": "^3.2.5",
@@ -80,9 +79,9 @@
80
79
  "@psf/bitcoincashjs-lib": "^4.0.3",
81
80
  "@xchainjs/xchain-client": "^0.16.2",
82
81
  "@xchainjs/xchain-crypto": "^0.3.1",
83
- "@xchainjs/xchain-thornode": "^0.3.11",
82
+ "@xchainjs/xchain-thornode": "^0.3.12",
84
83
  "@xchainjs/xchain-evm": "^0.4.5",
85
- "@xchainjs/xchain-midgard": "^0.5.2",
84
+ "@xchainjs/xchain-midgard": "^0.5.4",
86
85
  "@xchainjs/xchain-util": "^0.13.3",
87
86
  "@xchainjs/xchain-utxo-providers": "^0.2.12",
88
87
  "axios": "^1.3.6",