@xchainjs/xchain-thorchain-amm 0.4.0 → 0.5.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.esm.js CHANGED
@@ -325,7 +325,7 @@ class Wallet {
325
325
  const isThorchainDestinationAsset = swap.destinationAsset.synth || swap.destinationAsset.chain === THORChain;
326
326
  const chain = isThorchainDestinationAsset ? THORChain : swap.destinationAsset.chain;
327
327
  // check address
328
- if (!this.clients[chain].validateAddress(swap.destinationAddress)) {
328
+ if (swap.destinationAddress && !this.clients[chain].validateAddress(swap.destinationAddress)) {
329
329
  errors.push(`destinationAddress ${swap.destinationAddress} is not a valid address`);
330
330
  }
331
331
  // Affiliate address should be THORName or THORAddress
@@ -386,13 +386,12 @@ class Wallet {
386
386
  swapRuneTo(swap) {
387
387
  return __awaiter(this, void 0, void 0, function* () {
388
388
  const thorClient = this.clients.THOR;
389
- const waitTimeSeconds = swap.waitTimeSeconds;
390
389
  const hash = yield thorClient.deposit({
391
390
  amount: swap.input.baseAmount,
392
391
  asset: swap.input.asset,
393
392
  memo: swap.memo,
394
393
  });
395
- return { hash, url: this.clients.THOR.getExplorerTxUrl(hash), waitTimeSeconds };
394
+ return { hash, url: this.clients.THOR.getExplorerTxUrl(hash) };
396
395
  });
397
396
  }
398
397
  /** Function handles all swaps from Non Rune
@@ -403,7 +402,6 @@ class Wallet {
403
402
  swapNonRune(swap) {
404
403
  return __awaiter(this, void 0, void 0, function* () {
405
404
  const client = this.clients[swap.input.asset.chain];
406
- const waitTimeSeconds = swap.waitTimeSeconds;
407
405
  const inbound = (yield this.thorchainQuery.thorchainCache.getInboundDetails())[swap.input.asset.chain];
408
406
  if (!(inbound === null || inbound === void 0 ? void 0 : inbound.address))
409
407
  throw Error(`no asgard address found for ${swap.input.asset.chain}`);
@@ -416,7 +414,7 @@ class Wallet {
416
414
  memo: swap.memo,
417
415
  };
418
416
  const hash = yield this.ethHelper.sendDeposit(params);
419
- return { hash, url: client.getExplorerTxUrl(hash), waitTimeSeconds };
417
+ return { hash, url: client.getExplorerTxUrl(hash) };
420
418
  }
421
419
  else if (swap.input.asset.chain === AVAXChain) {
422
420
  const params = {
@@ -427,7 +425,7 @@ class Wallet {
427
425
  memo: swap.memo,
428
426
  };
429
427
  const hash = yield this.evmHelpers['AVAX'].sendDeposit(params);
430
- return { hash, url: client.getExplorerTxUrl(hash), waitTimeSeconds };
428
+ return { hash, url: client.getExplorerTxUrl(hash) };
431
429
  }
432
430
  else if (swap.input.asset.chain === BSCChain) {
433
431
  const params = {
@@ -438,7 +436,7 @@ class Wallet {
438
436
  memo: swap.memo,
439
437
  };
440
438
  const hash = yield this.evmHelpers['BSC'].sendDeposit(params);
441
- return { hash, url: client.getExplorerTxUrl(hash), waitTimeSeconds };
439
+ return { hash, url: client.getExplorerTxUrl(hash) };
442
440
  }
443
441
  else {
444
442
  const params = {
@@ -449,7 +447,7 @@ class Wallet {
449
447
  memo: swap.memo,
450
448
  };
451
449
  const hash = yield client.transfer(params);
452
- return { hash, url: client.getExplorerTxUrl(hash), waitTimeSeconds };
450
+ return { hash, url: client.getExplorerTxUrl(hash) };
453
451
  }
454
452
  });
455
453
  }
@@ -466,27 +464,27 @@ class Wallet {
466
464
  const thorchainClient = this.clients[params.rune.asset.chain];
467
465
  const addressRune = thorchainClient.getAddress();
468
466
  const addressAsset = assetClient.getAddress();
469
- const waitTimeSeconds = params.waitTimeSeconds;
467
+ // const waitTimeSeconds = params.waitTimeSeconds
470
468
  let constructedMemo = '';
471
469
  const txSubmitted = [];
472
470
  // symmetrical add
473
471
  if (params.asset.assetAmount.gt(0) && params.rune.assetAmount.gt(0)) {
474
472
  constructedMemo = `+:${params.assetPool}:${addressRune}`;
475
- txSubmitted.push(yield this.addAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
473
+ txSubmitted.push(yield this.addAssetLP(params, constructedMemo, assetClient, inboundAsgard));
476
474
  constructedMemo = `+:${params.assetPool}:${addressAsset}`;
477
- txSubmitted.push(yield this.addRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
475
+ txSubmitted.push(yield this.addRuneLP(params, constructedMemo, thorchainClient));
478
476
  return txSubmitted;
479
477
  }
480
478
  else if (params.asset.assetAmount.gt(0) && params.rune.assetAmount.eq(0)) {
481
479
  // asymmetrical asset only
482
480
  constructedMemo = `+:${params.assetPool}`;
483
- txSubmitted.push(yield this.addAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
481
+ txSubmitted.push(yield this.addAssetLP(params, constructedMemo, assetClient, inboundAsgard));
484
482
  return txSubmitted;
485
483
  }
486
484
  else {
487
485
  // asymmetrical rune only
488
486
  constructedMemo = `+:${params.assetPool}`;
489
- txSubmitted.push(yield this.addRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
487
+ txSubmitted.push(yield this.addRuneLP(params, constructedMemo, thorchainClient));
490
488
  return txSubmitted;
491
489
  }
492
490
  });
@@ -501,28 +499,28 @@ class Wallet {
501
499
  const assetClient = this.clients[params.assetFee.asset.chain];
502
500
  const inboundAsgard = (yield this.thorchainQuery.thorchainCache.getInboundDetails())[params.assetFee.asset.chain]
503
501
  .address;
504
- const waitTimeSeconds = params.waitTimeSeconds;
502
+ // const waitTimeSeconds = params.waitTimeSeconds
505
503
  const thorchainClient = this.clients[params.runeFee.asset.chain];
506
504
  const basisPoints = (params.percentage * 100).toFixed(); // convert to basis points
507
505
  let constructedMemo = '';
508
506
  const txSubmitted = [];
509
507
  if (params.assetAddress && params.runeAddress) {
510
508
  constructedMemo = `-:${params.assetPool}:${basisPoints}`;
511
- txSubmitted.push(yield this.withdrawAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
509
+ txSubmitted.push(yield this.withdrawAssetLP(params, constructedMemo, assetClient, inboundAsgard));
512
510
  constructedMemo = `-:${params.assetPool}:${basisPoints}`;
513
- txSubmitted.push(yield this.withdrawRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
511
+ txSubmitted.push(yield this.withdrawRuneLP(params, constructedMemo, thorchainClient));
514
512
  return txSubmitted;
515
513
  }
516
514
  else if (params.assetAddress && !params.runeAddress) {
517
515
  // asymmetrical asset only
518
516
  constructedMemo = `-:${params.assetPool}:${basisPoints}`;
519
- txSubmitted.push(yield this.withdrawAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
517
+ txSubmitted.push(yield this.withdrawAssetLP(params, constructedMemo, assetClient, inboundAsgard));
520
518
  return txSubmitted;
521
519
  }
522
520
  else {
523
521
  // asymmetrical rune only
524
522
  constructedMemo = `-:${params.assetPool}:${basisPoints}`;
525
- txSubmitted.push(yield this.withdrawRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
523
+ txSubmitted.push(yield this.withdrawRuneLP(params, constructedMemo, thorchainClient));
526
524
  return txSubmitted;
527
525
  }
528
526
  });
@@ -534,7 +532,7 @@ class Wallet {
534
532
  * @param waitTimeSeconds - expected wait for the transaction to be processed
535
533
  * @returns
536
534
  */
537
- addSavers(assetAmount, memo, toAddress, waitTimeSeconds) {
535
+ addSavers(assetAmount, memo, toAddress) {
538
536
  return __awaiter(this, void 0, void 0, function* () {
539
537
  const assetClient = this.clients[assetAmount.asset.chain];
540
538
  if (assetAmount.asset.chain === ETHChain) {
@@ -546,7 +544,7 @@ class Wallet {
546
544
  memo: memo,
547
545
  };
548
546
  const hash = yield this.ethHelper.sendDeposit(addParams);
549
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
547
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
550
548
  }
551
549
  else if (assetAmount.asset.chain === AVAXChain) {
552
550
  const addParams = {
@@ -558,7 +556,7 @@ class Wallet {
558
556
  };
559
557
  const evmHelper = new EvmHelper(this.clients.AVAX, this.thorchainQuery.thorchainCache);
560
558
  const hash = yield evmHelper.sendDeposit(addParams);
561
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
559
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
562
560
  }
563
561
  else if (assetAmount.asset.chain === BSCChain) {
564
562
  const addParams = {
@@ -570,7 +568,7 @@ class Wallet {
570
568
  };
571
569
  const evmHelper = new EvmHelper(this.clients.BSC, this.thorchainQuery.thorchainCache);
572
570
  const hash = yield evmHelper.sendDeposit(addParams);
573
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
571
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
574
572
  }
575
573
  else {
576
574
  const addParams = {
@@ -582,11 +580,11 @@ class Wallet {
582
580
  };
583
581
  try {
584
582
  const hash = yield assetClient.transfer(addParams);
585
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
583
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
586
584
  }
587
585
  catch (err) {
588
586
  const hash = JSON.stringify(err);
589
- return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()), waitTimeSeconds };
587
+ return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()) };
590
588
  }
591
589
  }
592
590
  });
@@ -598,7 +596,7 @@ class Wallet {
598
596
  * @param waitTimeSeconds - expected wait for the transaction to be processed
599
597
  * @returns
600
598
  */
601
- withdrawSavers(dustAssetAmount, memo, toAddress, waitTimeSeconds) {
599
+ withdrawSavers(dustAssetAmount, memo, toAddress) {
602
600
  return __awaiter(this, void 0, void 0, function* () {
603
601
  const assetClient = this.clients[dustAssetAmount.asset.chain];
604
602
  if (dustAssetAmount.asset.chain === ETHChain) {
@@ -610,7 +608,7 @@ class Wallet {
610
608
  memo: memo,
611
609
  };
612
610
  const hash = yield this.ethHelper.sendDeposit(addParams);
613
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
611
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
614
612
  }
615
613
  else if (dustAssetAmount.asset.chain === AVAXChain) {
616
614
  const addParams = {
@@ -622,7 +620,7 @@ class Wallet {
622
620
  };
623
621
  const evmHelper = new EvmHelper(this.clients.AVAX, this.thorchainQuery.thorchainCache);
624
622
  const hash = yield evmHelper.sendDeposit(addParams);
625
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
623
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
626
624
  }
627
625
  else if (dustAssetAmount.asset.chain === BSCChain) {
628
626
  const addParams = {
@@ -634,7 +632,7 @@ class Wallet {
634
632
  };
635
633
  const evmHelper = new EvmHelper(this.clients.BSC, this.thorchainQuery.thorchainCache);
636
634
  const hash = yield evmHelper.sendDeposit(addParams);
637
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
635
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
638
636
  }
639
637
  else {
640
638
  const addParams = {
@@ -646,11 +644,11 @@ class Wallet {
646
644
  };
647
645
  try {
648
646
  const hash = yield assetClient.transfer(addParams);
649
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
647
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
650
648
  }
651
649
  catch (err) {
652
650
  const hash = JSON.stringify(err);
653
- return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()), waitTimeSeconds };
651
+ return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()) };
654
652
  }
655
653
  }
656
654
  });
@@ -664,7 +662,7 @@ class Wallet {
664
662
  * @param inboundAsgard - inbound Asgard address for the LP
665
663
  * @returns - tx object
666
664
  */
667
- addAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard) {
665
+ addAssetLP(params, constructedMemo, assetClient, inboundAsgard) {
668
666
  return __awaiter(this, void 0, void 0, function* () {
669
667
  if (params.asset.asset.chain === ETHChain) {
670
668
  const addParams = {
@@ -675,7 +673,7 @@ class Wallet {
675
673
  memo: constructedMemo,
676
674
  };
677
675
  const hash = yield this.ethHelper.sendDeposit(addParams);
678
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
676
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
679
677
  }
680
678
  else if (params.asset.asset.chain === AVAXChain) {
681
679
  const addParams = {
@@ -687,7 +685,7 @@ class Wallet {
687
685
  };
688
686
  const evmHelper = new EvmHelper(this.clients.AVAX, this.thorchainQuery.thorchainCache);
689
687
  const hash = yield evmHelper.sendDeposit(addParams);
690
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
688
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
691
689
  }
692
690
  else if (params.asset.asset.chain === BSCChain) {
693
691
  const addParams = {
@@ -699,7 +697,7 @@ class Wallet {
699
697
  };
700
698
  const evmHelper = new EvmHelper(this.clients.BSC, this.thorchainQuery.thorchainCache);
701
699
  const hash = yield evmHelper.sendDeposit(addParams);
702
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
700
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
703
701
  }
704
702
  else {
705
703
  const addParams = {
@@ -711,11 +709,11 @@ class Wallet {
711
709
  };
712
710
  try {
713
711
  const hash = yield assetClient.transfer(addParams);
714
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
712
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
715
713
  }
716
714
  catch (err) {
717
715
  const hash = JSON.stringify(err);
718
- return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()), waitTimeSeconds };
716
+ return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()) };
719
717
  }
720
718
  }
721
719
  });
@@ -729,7 +727,7 @@ class Wallet {
729
727
  * @param inboundAsgard - destination address
730
728
  * @returns - tx object
731
729
  */
732
- withdrawAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard) {
730
+ withdrawAssetLP(params, constructedMemo, assetClient, inboundAsgard) {
733
731
  return __awaiter(this, void 0, void 0, function* () {
734
732
  if (params.assetFee.asset.chain === ETHChain) {
735
733
  const withdrawParams = {
@@ -741,7 +739,7 @@ class Wallet {
741
739
  };
742
740
  // console.log(withdrawParams.amount.amount().toNumber())
743
741
  const hash = yield this.ethHelper.sendDeposit(withdrawParams);
744
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
742
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
745
743
  }
746
744
  else if (params.assetFee.asset.chain === AVAXChain) {
747
745
  const withdrawParams = {
@@ -753,7 +751,7 @@ class Wallet {
753
751
  };
754
752
  const evmHelper = new EvmHelper(this.clients.AVAX, this.thorchainQuery.thorchainCache);
755
753
  const hash = yield evmHelper.sendDeposit(withdrawParams);
756
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
754
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
757
755
  }
758
756
  else if (params.assetFee.asset.chain === BSCChain) {
759
757
  const withdrawParams = {
@@ -765,7 +763,7 @@ class Wallet {
765
763
  };
766
764
  const evmHelper = new EvmHelper(this.clients.BSC, this.thorchainQuery.thorchainCache);
767
765
  const hash = yield evmHelper.sendDeposit(withdrawParams);
768
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
766
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
769
767
  }
770
768
  else {
771
769
  const withdrawParams = {
@@ -777,11 +775,11 @@ class Wallet {
777
775
  };
778
776
  try {
779
777
  const hash = yield assetClient.transfer(withdrawParams);
780
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
778
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
781
779
  }
782
780
  catch (err) {
783
781
  const hash = JSON.stringify(err);
784
- return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()), waitTimeSeconds };
782
+ return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()) };
785
783
  }
786
784
  }
787
785
  });
@@ -792,7 +790,7 @@ class Wallet {
792
790
  * @param memo - memo needed to withdraw lp
793
791
  * @returns - tx object
794
792
  */
795
- addRuneLP(params, memo, thorchainClient, waitTimeSeconds) {
793
+ addRuneLP(params, memo, thorchainClient) {
796
794
  return __awaiter(this, void 0, void 0, function* () {
797
795
  const thorClient = this.clients.THOR;
798
796
  const addParams = {
@@ -801,7 +799,7 @@ class Wallet {
801
799
  memo: memo,
802
800
  };
803
801
  const hash = yield thorClient.deposit(addParams);
804
- return { hash, url: thorchainClient.getExplorerTxUrl(hash), waitTimeSeconds };
802
+ return { hash, url: thorchainClient.getExplorerTxUrl(hash) };
805
803
  });
806
804
  }
807
805
  /** Function handles liquidity Withdraw for Rune only
@@ -810,7 +808,7 @@ class Wallet {
810
808
  * @param memo - memo needed to withdraw lp
811
809
  * @returns - tx object
812
810
  */
813
- withdrawRuneLP(params, memo, thorchainClient, waitTimeSeconds) {
811
+ withdrawRuneLP(params, memo, thorchainClient) {
814
812
  return __awaiter(this, void 0, void 0, function* () {
815
813
  const thorClient = this.clients.THOR;
816
814
  const addParams = {
@@ -819,7 +817,7 @@ class Wallet {
819
817
  memo: memo,
820
818
  };
821
819
  const hash = yield thorClient.deposit(addParams);
822
- return { hash, url: thorchainClient.getExplorerTxUrl(hash), waitTimeSeconds };
820
+ return { hash, url: thorchainClient.getExplorerTxUrl(hash) };
823
821
  });
824
822
  }
825
823
  }
@@ -848,12 +846,12 @@ class ThorchainAMM {
848
846
 
849
847
  * @returns The SwapEstimate
850
848
  */
851
- estimateSwap({ input, destinationAsset, destinationAddress, affiliateAddress = '', interfaceID = `555`, affiliateFeeBasisPoints = 0, slipLimit, wallet, walletIndex, }) {
849
+ estimateSwap({ fromAsset, amount, fromAddress, destinationAsset, destinationAddress, affiliateAddress = '', interfaceID = `555`, affiliateBps = 0, toleranceBps, wallet, walletIndex, }) {
852
850
  return __awaiter(this, void 0, void 0, function* () {
853
851
  let errors = [];
854
852
  if (wallet) {
855
853
  const params = {
856
- input,
854
+ input: amount,
857
855
  destinationAsset,
858
856
  destinationAddress,
859
857
  memo: '',
@@ -862,14 +860,16 @@ class ThorchainAMM {
862
860
  };
863
861
  errors = yield wallet.validateSwap(params);
864
862
  }
865
- const estimate = yield this.thorchainQuery.estimateSwap({
866
- input,
863
+ const estimate = yield this.thorchainQuery.quoteSwap({
864
+ fromAsset,
865
+ amount,
866
+ fromAddress,
867
867
  destinationAsset,
868
868
  destinationAddress,
869
869
  affiliateAddress,
870
870
  interfaceID,
871
- affiliateFeeBasisPoints,
872
- slipLimit,
871
+ affiliateBps,
872
+ toleranceBps,
873
873
  });
874
874
  estimate.txEstimate.errors.push(...errors);
875
875
  estimate.txEstimate.canSwap = errors.length == 0;
@@ -886,16 +886,15 @@ class ThorchainAMM {
886
886
  doSwap(wallet, params) {
887
887
  return __awaiter(this, void 0, void 0, function* () {
888
888
  // Thorchain-query call satisfies the data needed for executeSwap to be called.
889
- const txDetails = yield this.thorchainQuery.estimateSwap(params);
889
+ const txDetails = yield this.thorchainQuery.quoteSwap(params);
890
890
  if (!txDetails.txEstimate.canSwap) {
891
891
  throw Error(txDetails.txEstimate.errors.join('\n'));
892
892
  }
893
893
  return yield wallet.executeSwap({
894
- input: params.input,
894
+ input: params.amount,
895
895
  destinationAsset: params.destinationAsset,
896
896
  destinationAddress: params.destinationAddress,
897
897
  memo: txDetails.memo,
898
- waitTimeSeconds: txDetails.txEstimate.waitTimeSeconds,
899
898
  walletIndex: params.walletIndex,
900
899
  feeOption: params.feeOption,
901
900
  });
@@ -1003,7 +1002,7 @@ class ThorchainAMM {
1003
1002
  const addEstimate = yield this.thorchainQuery.estimateAddSaver(addAssetAmount);
1004
1003
  if (!addEstimate.canAddSaver)
1005
1004
  throw Error(`Cannot add to savers`);
1006
- return yield wallet.addSavers(addAssetAmount, addEstimate.memo, addEstimate.toAddress, addEstimate.estimatedWaitTime);
1005
+ return yield wallet.addSavers(addAssetAmount, addEstimate.memo, addEstimate.toAddress);
1007
1006
  });
1008
1007
  }
1009
1008
  /**
@@ -1017,7 +1016,7 @@ class ThorchainAMM {
1017
1016
  const withdrawEstimate = yield this.thorchainQuery.estimateWithdrawSaver(withdrawParams);
1018
1017
  if (withdrawEstimate.errors.length > 0)
1019
1018
  throw Error(`${withdrawEstimate.errors}`);
1020
- return yield wallet.withdrawSavers(withdrawEstimate.dustAmount, withdrawEstimate.memo, withdrawEstimate.toAddress, withdrawEstimate.estimatedWaitTime);
1019
+ return yield wallet.withdrawSavers(withdrawEstimate.dustAmount, withdrawEstimate.memo, withdrawEstimate.toAddress);
1021
1020
  });
1022
1021
  }
1023
1022
  }
package/lib/index.js CHANGED
@@ -329,7 +329,7 @@ class Wallet {
329
329
  const isThorchainDestinationAsset = swap.destinationAsset.synth || swap.destinationAsset.chain === xchainThorchain.THORChain;
330
330
  const chain = isThorchainDestinationAsset ? xchainThorchain.THORChain : swap.destinationAsset.chain;
331
331
  // check address
332
- if (!this.clients[chain].validateAddress(swap.destinationAddress)) {
332
+ if (swap.destinationAddress && !this.clients[chain].validateAddress(swap.destinationAddress)) {
333
333
  errors.push(`destinationAddress ${swap.destinationAddress} is not a valid address`);
334
334
  }
335
335
  // Affiliate address should be THORName or THORAddress
@@ -390,13 +390,12 @@ class Wallet {
390
390
  swapRuneTo(swap) {
391
391
  return __awaiter(this, void 0, void 0, function* () {
392
392
  const thorClient = this.clients.THOR;
393
- const waitTimeSeconds = swap.waitTimeSeconds;
394
393
  const hash = yield thorClient.deposit({
395
394
  amount: swap.input.baseAmount,
396
395
  asset: swap.input.asset,
397
396
  memo: swap.memo,
398
397
  });
399
- return { hash, url: this.clients.THOR.getExplorerTxUrl(hash), waitTimeSeconds };
398
+ return { hash, url: this.clients.THOR.getExplorerTxUrl(hash) };
400
399
  });
401
400
  }
402
401
  /** Function handles all swaps from Non Rune
@@ -407,7 +406,6 @@ class Wallet {
407
406
  swapNonRune(swap) {
408
407
  return __awaiter(this, void 0, void 0, function* () {
409
408
  const client = this.clients[swap.input.asset.chain];
410
- const waitTimeSeconds = swap.waitTimeSeconds;
411
409
  const inbound = (yield this.thorchainQuery.thorchainCache.getInboundDetails())[swap.input.asset.chain];
412
410
  if (!(inbound === null || inbound === void 0 ? void 0 : inbound.address))
413
411
  throw Error(`no asgard address found for ${swap.input.asset.chain}`);
@@ -420,7 +418,7 @@ class Wallet {
420
418
  memo: swap.memo,
421
419
  };
422
420
  const hash = yield this.ethHelper.sendDeposit(params);
423
- return { hash, url: client.getExplorerTxUrl(hash), waitTimeSeconds };
421
+ return { hash, url: client.getExplorerTxUrl(hash) };
424
422
  }
425
423
  else if (swap.input.asset.chain === xchainAvax.AVAXChain) {
426
424
  const params = {
@@ -431,7 +429,7 @@ class Wallet {
431
429
  memo: swap.memo,
432
430
  };
433
431
  const hash = yield this.evmHelpers['AVAX'].sendDeposit(params);
434
- return { hash, url: client.getExplorerTxUrl(hash), waitTimeSeconds };
432
+ return { hash, url: client.getExplorerTxUrl(hash) };
435
433
  }
436
434
  else if (swap.input.asset.chain === xchainBsc.BSCChain) {
437
435
  const params = {
@@ -442,7 +440,7 @@ class Wallet {
442
440
  memo: swap.memo,
443
441
  };
444
442
  const hash = yield this.evmHelpers['BSC'].sendDeposit(params);
445
- return { hash, url: client.getExplorerTxUrl(hash), waitTimeSeconds };
443
+ return { hash, url: client.getExplorerTxUrl(hash) };
446
444
  }
447
445
  else {
448
446
  const params = {
@@ -453,7 +451,7 @@ class Wallet {
453
451
  memo: swap.memo,
454
452
  };
455
453
  const hash = yield client.transfer(params);
456
- return { hash, url: client.getExplorerTxUrl(hash), waitTimeSeconds };
454
+ return { hash, url: client.getExplorerTxUrl(hash) };
457
455
  }
458
456
  });
459
457
  }
@@ -470,27 +468,27 @@ class Wallet {
470
468
  const thorchainClient = this.clients[params.rune.asset.chain];
471
469
  const addressRune = thorchainClient.getAddress();
472
470
  const addressAsset = assetClient.getAddress();
473
- const waitTimeSeconds = params.waitTimeSeconds;
471
+ // const waitTimeSeconds = params.waitTimeSeconds
474
472
  let constructedMemo = '';
475
473
  const txSubmitted = [];
476
474
  // symmetrical add
477
475
  if (params.asset.assetAmount.gt(0) && params.rune.assetAmount.gt(0)) {
478
476
  constructedMemo = `+:${params.assetPool}:${addressRune}`;
479
- txSubmitted.push(yield this.addAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
477
+ txSubmitted.push(yield this.addAssetLP(params, constructedMemo, assetClient, inboundAsgard));
480
478
  constructedMemo = `+:${params.assetPool}:${addressAsset}`;
481
- txSubmitted.push(yield this.addRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
479
+ txSubmitted.push(yield this.addRuneLP(params, constructedMemo, thorchainClient));
482
480
  return txSubmitted;
483
481
  }
484
482
  else if (params.asset.assetAmount.gt(0) && params.rune.assetAmount.eq(0)) {
485
483
  // asymmetrical asset only
486
484
  constructedMemo = `+:${params.assetPool}`;
487
- txSubmitted.push(yield this.addAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
485
+ txSubmitted.push(yield this.addAssetLP(params, constructedMemo, assetClient, inboundAsgard));
488
486
  return txSubmitted;
489
487
  }
490
488
  else {
491
489
  // asymmetrical rune only
492
490
  constructedMemo = `+:${params.assetPool}`;
493
- txSubmitted.push(yield this.addRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
491
+ txSubmitted.push(yield this.addRuneLP(params, constructedMemo, thorchainClient));
494
492
  return txSubmitted;
495
493
  }
496
494
  });
@@ -505,28 +503,28 @@ class Wallet {
505
503
  const assetClient = this.clients[params.assetFee.asset.chain];
506
504
  const inboundAsgard = (yield this.thorchainQuery.thorchainCache.getInboundDetails())[params.assetFee.asset.chain]
507
505
  .address;
508
- const waitTimeSeconds = params.waitTimeSeconds;
506
+ // const waitTimeSeconds = params.waitTimeSeconds
509
507
  const thorchainClient = this.clients[params.runeFee.asset.chain];
510
508
  const basisPoints = (params.percentage * 100).toFixed(); // convert to basis points
511
509
  let constructedMemo = '';
512
510
  const txSubmitted = [];
513
511
  if (params.assetAddress && params.runeAddress) {
514
512
  constructedMemo = `-:${params.assetPool}:${basisPoints}`;
515
- txSubmitted.push(yield this.withdrawAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
513
+ txSubmitted.push(yield this.withdrawAssetLP(params, constructedMemo, assetClient, inboundAsgard));
516
514
  constructedMemo = `-:${params.assetPool}:${basisPoints}`;
517
- txSubmitted.push(yield this.withdrawRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
515
+ txSubmitted.push(yield this.withdrawRuneLP(params, constructedMemo, thorchainClient));
518
516
  return txSubmitted;
519
517
  }
520
518
  else if (params.assetAddress && !params.runeAddress) {
521
519
  // asymmetrical asset only
522
520
  constructedMemo = `-:${params.assetPool}:${basisPoints}`;
523
- txSubmitted.push(yield this.withdrawAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard));
521
+ txSubmitted.push(yield this.withdrawAssetLP(params, constructedMemo, assetClient, inboundAsgard));
524
522
  return txSubmitted;
525
523
  }
526
524
  else {
527
525
  // asymmetrical rune only
528
526
  constructedMemo = `-:${params.assetPool}:${basisPoints}`;
529
- txSubmitted.push(yield this.withdrawRuneLP(params, constructedMemo, thorchainClient, waitTimeSeconds));
527
+ txSubmitted.push(yield this.withdrawRuneLP(params, constructedMemo, thorchainClient));
530
528
  return txSubmitted;
531
529
  }
532
530
  });
@@ -538,7 +536,7 @@ class Wallet {
538
536
  * @param waitTimeSeconds - expected wait for the transaction to be processed
539
537
  * @returns
540
538
  */
541
- addSavers(assetAmount, memo, toAddress, waitTimeSeconds) {
539
+ addSavers(assetAmount, memo, toAddress) {
542
540
  return __awaiter(this, void 0, void 0, function* () {
543
541
  const assetClient = this.clients[assetAmount.asset.chain];
544
542
  if (assetAmount.asset.chain === xchainEthereum.ETHChain) {
@@ -550,7 +548,7 @@ class Wallet {
550
548
  memo: memo,
551
549
  };
552
550
  const hash = yield this.ethHelper.sendDeposit(addParams);
553
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
551
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
554
552
  }
555
553
  else if (assetAmount.asset.chain === xchainAvax.AVAXChain) {
556
554
  const addParams = {
@@ -562,7 +560,7 @@ class Wallet {
562
560
  };
563
561
  const evmHelper = new EvmHelper(this.clients.AVAX, this.thorchainQuery.thorchainCache);
564
562
  const hash = yield evmHelper.sendDeposit(addParams);
565
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
563
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
566
564
  }
567
565
  else if (assetAmount.asset.chain === xchainBsc.BSCChain) {
568
566
  const addParams = {
@@ -574,7 +572,7 @@ class Wallet {
574
572
  };
575
573
  const evmHelper = new EvmHelper(this.clients.BSC, this.thorchainQuery.thorchainCache);
576
574
  const hash = yield evmHelper.sendDeposit(addParams);
577
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
575
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
578
576
  }
579
577
  else {
580
578
  const addParams = {
@@ -586,11 +584,11 @@ class Wallet {
586
584
  };
587
585
  try {
588
586
  const hash = yield assetClient.transfer(addParams);
589
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
587
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
590
588
  }
591
589
  catch (err) {
592
590
  const hash = JSON.stringify(err);
593
- return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()), waitTimeSeconds };
591
+ return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()) };
594
592
  }
595
593
  }
596
594
  });
@@ -602,7 +600,7 @@ class Wallet {
602
600
  * @param waitTimeSeconds - expected wait for the transaction to be processed
603
601
  * @returns
604
602
  */
605
- withdrawSavers(dustAssetAmount, memo, toAddress, waitTimeSeconds) {
603
+ withdrawSavers(dustAssetAmount, memo, toAddress) {
606
604
  return __awaiter(this, void 0, void 0, function* () {
607
605
  const assetClient = this.clients[dustAssetAmount.asset.chain];
608
606
  if (dustAssetAmount.asset.chain === xchainEthereum.ETHChain) {
@@ -614,7 +612,7 @@ class Wallet {
614
612
  memo: memo,
615
613
  };
616
614
  const hash = yield this.ethHelper.sendDeposit(addParams);
617
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
615
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
618
616
  }
619
617
  else if (dustAssetAmount.asset.chain === xchainAvax.AVAXChain) {
620
618
  const addParams = {
@@ -626,7 +624,7 @@ class Wallet {
626
624
  };
627
625
  const evmHelper = new EvmHelper(this.clients.AVAX, this.thorchainQuery.thorchainCache);
628
626
  const hash = yield evmHelper.sendDeposit(addParams);
629
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
627
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
630
628
  }
631
629
  else if (dustAssetAmount.asset.chain === xchainBsc.BSCChain) {
632
630
  const addParams = {
@@ -638,7 +636,7 @@ class Wallet {
638
636
  };
639
637
  const evmHelper = new EvmHelper(this.clients.BSC, this.thorchainQuery.thorchainCache);
640
638
  const hash = yield evmHelper.sendDeposit(addParams);
641
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
639
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
642
640
  }
643
641
  else {
644
642
  const addParams = {
@@ -650,11 +648,11 @@ class Wallet {
650
648
  };
651
649
  try {
652
650
  const hash = yield assetClient.transfer(addParams);
653
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
651
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
654
652
  }
655
653
  catch (err) {
656
654
  const hash = JSON.stringify(err);
657
- return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()), waitTimeSeconds };
655
+ return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()) };
658
656
  }
659
657
  }
660
658
  });
@@ -668,7 +666,7 @@ class Wallet {
668
666
  * @param inboundAsgard - inbound Asgard address for the LP
669
667
  * @returns - tx object
670
668
  */
671
- addAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard) {
669
+ addAssetLP(params, constructedMemo, assetClient, inboundAsgard) {
672
670
  return __awaiter(this, void 0, void 0, function* () {
673
671
  if (params.asset.asset.chain === xchainEthereum.ETHChain) {
674
672
  const addParams = {
@@ -679,7 +677,7 @@ class Wallet {
679
677
  memo: constructedMemo,
680
678
  };
681
679
  const hash = yield this.ethHelper.sendDeposit(addParams);
682
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
680
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
683
681
  }
684
682
  else if (params.asset.asset.chain === xchainAvax.AVAXChain) {
685
683
  const addParams = {
@@ -691,7 +689,7 @@ class Wallet {
691
689
  };
692
690
  const evmHelper = new EvmHelper(this.clients.AVAX, this.thorchainQuery.thorchainCache);
693
691
  const hash = yield evmHelper.sendDeposit(addParams);
694
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
692
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
695
693
  }
696
694
  else if (params.asset.asset.chain === xchainBsc.BSCChain) {
697
695
  const addParams = {
@@ -703,7 +701,7 @@ class Wallet {
703
701
  };
704
702
  const evmHelper = new EvmHelper(this.clients.BSC, this.thorchainQuery.thorchainCache);
705
703
  const hash = yield evmHelper.sendDeposit(addParams);
706
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
704
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
707
705
  }
708
706
  else {
709
707
  const addParams = {
@@ -715,11 +713,11 @@ class Wallet {
715
713
  };
716
714
  try {
717
715
  const hash = yield assetClient.transfer(addParams);
718
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
716
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
719
717
  }
720
718
  catch (err) {
721
719
  const hash = JSON.stringify(err);
722
- return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()), waitTimeSeconds };
720
+ return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()) };
723
721
  }
724
722
  }
725
723
  });
@@ -733,7 +731,7 @@ class Wallet {
733
731
  * @param inboundAsgard - destination address
734
732
  * @returns - tx object
735
733
  */
736
- withdrawAssetLP(params, constructedMemo, assetClient, waitTimeSeconds, inboundAsgard) {
734
+ withdrawAssetLP(params, constructedMemo, assetClient, inboundAsgard) {
737
735
  return __awaiter(this, void 0, void 0, function* () {
738
736
  if (params.assetFee.asset.chain === xchainEthereum.ETHChain) {
739
737
  const withdrawParams = {
@@ -745,7 +743,7 @@ class Wallet {
745
743
  };
746
744
  // console.log(withdrawParams.amount.amount().toNumber())
747
745
  const hash = yield this.ethHelper.sendDeposit(withdrawParams);
748
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
746
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
749
747
  }
750
748
  else if (params.assetFee.asset.chain === xchainAvax.AVAXChain) {
751
749
  const withdrawParams = {
@@ -757,7 +755,7 @@ class Wallet {
757
755
  };
758
756
  const evmHelper = new EvmHelper(this.clients.AVAX, this.thorchainQuery.thorchainCache);
759
757
  const hash = yield evmHelper.sendDeposit(withdrawParams);
760
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
758
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
761
759
  }
762
760
  else if (params.assetFee.asset.chain === xchainBsc.BSCChain) {
763
761
  const withdrawParams = {
@@ -769,7 +767,7 @@ class Wallet {
769
767
  };
770
768
  const evmHelper = new EvmHelper(this.clients.BSC, this.thorchainQuery.thorchainCache);
771
769
  const hash = yield evmHelper.sendDeposit(withdrawParams);
772
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
770
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
773
771
  }
774
772
  else {
775
773
  const withdrawParams = {
@@ -781,11 +779,11 @@ class Wallet {
781
779
  };
782
780
  try {
783
781
  const hash = yield assetClient.transfer(withdrawParams);
784
- return { hash, url: assetClient.getExplorerTxUrl(hash), waitTimeSeconds };
782
+ return { hash, url: assetClient.getExplorerTxUrl(hash) };
785
783
  }
786
784
  catch (err) {
787
785
  const hash = JSON.stringify(err);
788
- return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()), waitTimeSeconds };
786
+ return { hash, url: assetClient.getExplorerAddressUrl(assetClient.getAddress()) };
789
787
  }
790
788
  }
791
789
  });
@@ -796,7 +794,7 @@ class Wallet {
796
794
  * @param memo - memo needed to withdraw lp
797
795
  * @returns - tx object
798
796
  */
799
- addRuneLP(params, memo, thorchainClient, waitTimeSeconds) {
797
+ addRuneLP(params, memo, thorchainClient) {
800
798
  return __awaiter(this, void 0, void 0, function* () {
801
799
  const thorClient = this.clients.THOR;
802
800
  const addParams = {
@@ -805,7 +803,7 @@ class Wallet {
805
803
  memo: memo,
806
804
  };
807
805
  const hash = yield thorClient.deposit(addParams);
808
- return { hash, url: thorchainClient.getExplorerTxUrl(hash), waitTimeSeconds };
806
+ return { hash, url: thorchainClient.getExplorerTxUrl(hash) };
809
807
  });
810
808
  }
811
809
  /** Function handles liquidity Withdraw for Rune only
@@ -814,7 +812,7 @@ class Wallet {
814
812
  * @param memo - memo needed to withdraw lp
815
813
  * @returns - tx object
816
814
  */
817
- withdrawRuneLP(params, memo, thorchainClient, waitTimeSeconds) {
815
+ withdrawRuneLP(params, memo, thorchainClient) {
818
816
  return __awaiter(this, void 0, void 0, function* () {
819
817
  const thorClient = this.clients.THOR;
820
818
  const addParams = {
@@ -823,7 +821,7 @@ class Wallet {
823
821
  memo: memo,
824
822
  };
825
823
  const hash = yield thorClient.deposit(addParams);
826
- return { hash, url: thorchainClient.getExplorerTxUrl(hash), waitTimeSeconds };
824
+ return { hash, url: thorchainClient.getExplorerTxUrl(hash) };
827
825
  });
828
826
  }
829
827
  }
@@ -852,12 +850,12 @@ class ThorchainAMM {
852
850
 
853
851
  * @returns The SwapEstimate
854
852
  */
855
- estimateSwap({ input, destinationAsset, destinationAddress, affiliateAddress = '', interfaceID = `555`, affiliateFeeBasisPoints = 0, slipLimit, wallet, walletIndex, }) {
853
+ estimateSwap({ fromAsset, amount, fromAddress, destinationAsset, destinationAddress, affiliateAddress = '', interfaceID = `555`, affiliateBps = 0, toleranceBps, wallet, walletIndex, }) {
856
854
  return __awaiter(this, void 0, void 0, function* () {
857
855
  let errors = [];
858
856
  if (wallet) {
859
857
  const params = {
860
- input,
858
+ input: amount,
861
859
  destinationAsset,
862
860
  destinationAddress,
863
861
  memo: '',
@@ -866,14 +864,16 @@ class ThorchainAMM {
866
864
  };
867
865
  errors = yield wallet.validateSwap(params);
868
866
  }
869
- const estimate = yield this.thorchainQuery.estimateSwap({
870
- input,
867
+ const estimate = yield this.thorchainQuery.quoteSwap({
868
+ fromAsset,
869
+ amount,
870
+ fromAddress,
871
871
  destinationAsset,
872
872
  destinationAddress,
873
873
  affiliateAddress,
874
874
  interfaceID,
875
- affiliateFeeBasisPoints,
876
- slipLimit,
875
+ affiliateBps,
876
+ toleranceBps,
877
877
  });
878
878
  estimate.txEstimate.errors.push(...errors);
879
879
  estimate.txEstimate.canSwap = errors.length == 0;
@@ -890,16 +890,15 @@ class ThorchainAMM {
890
890
  doSwap(wallet, params) {
891
891
  return __awaiter(this, void 0, void 0, function* () {
892
892
  // Thorchain-query call satisfies the data needed for executeSwap to be called.
893
- const txDetails = yield this.thorchainQuery.estimateSwap(params);
893
+ const txDetails = yield this.thorchainQuery.quoteSwap(params);
894
894
  if (!txDetails.txEstimate.canSwap) {
895
895
  throw Error(txDetails.txEstimate.errors.join('\n'));
896
896
  }
897
897
  return yield wallet.executeSwap({
898
- input: params.input,
898
+ input: params.amount,
899
899
  destinationAsset: params.destinationAsset,
900
900
  destinationAddress: params.destinationAddress,
901
901
  memo: txDetails.memo,
902
- waitTimeSeconds: txDetails.txEstimate.waitTimeSeconds,
903
902
  walletIndex: params.walletIndex,
904
903
  feeOption: params.feeOption,
905
904
  });
@@ -1007,7 +1006,7 @@ class ThorchainAMM {
1007
1006
  const addEstimate = yield this.thorchainQuery.estimateAddSaver(addAssetAmount);
1008
1007
  if (!addEstimate.canAddSaver)
1009
1008
  throw Error(`Cannot add to savers`);
1010
- return yield wallet.addSavers(addAssetAmount, addEstimate.memo, addEstimate.toAddress, addEstimate.estimatedWaitTime);
1009
+ return yield wallet.addSavers(addAssetAmount, addEstimate.memo, addEstimate.toAddress);
1011
1010
  });
1012
1011
  }
1013
1012
  /**
@@ -1021,7 +1020,7 @@ class ThorchainAMM {
1021
1020
  const withdrawEstimate = yield this.thorchainQuery.estimateWithdrawSaver(withdrawParams);
1022
1021
  if (withdrawEstimate.errors.length > 0)
1023
1022
  throw Error(`${withdrawEstimate.errors}`);
1024
- return yield wallet.withdrawSavers(withdrawEstimate.dustAmount, withdrawEstimate.memo, withdrawEstimate.toAddress, withdrawEstimate.estimatedWaitTime);
1023
+ return yield wallet.withdrawSavers(withdrawEstimate.dustAmount, withdrawEstimate.memo, withdrawEstimate.toAddress);
1025
1024
  });
1026
1025
  }
1027
1026
  }
@@ -1,7 +1,7 @@
1
- import { AddliquidityPosition, CryptoAmount, EstimateAddLP, EstimateAddSaver, EstimateSwapParams, EstimateWithdrawLP, EstimateWithdrawSaver, SaversPosition, SaversWithdraw, ThorchainQuery, TxDetails, WithdrawLiquidityPosition, getSaver } from '@xchainjs/xchain-thorchain-query';
1
+ import { AddliquidityPosition, CryptoAmount, EstimateAddLP, EstimateAddSaver, EstimateWithdrawLP, EstimateWithdrawSaver, QuoteSwapParams, SaversPosition, SaversWithdraw, ThorchainQuery, TxDetails, WithdrawLiquidityPosition, getSaver } from '@xchainjs/xchain-thorchain-query';
2
2
  import { TxSubmitted } from './types';
3
3
  import { Wallet } from './wallet';
4
- export type AmmEstimateSwapParams = EstimateSwapParams & {
4
+ export type AmmEstimateSwapParams = QuoteSwapParams & {
5
5
  wallet: Wallet;
6
6
  walletIndex: number;
7
7
  };
@@ -27,7 +27,7 @@ export declare class ThorchainAMM {
27
27
 
28
28
  * @returns The SwapEstimate
29
29
  */
30
- estimateSwap({ input, destinationAsset, destinationAddress, affiliateAddress, interfaceID, affiliateFeeBasisPoints, slipLimit, wallet, walletIndex, }: AmmEstimateSwapParams): Promise<TxDetails>;
30
+ estimateSwap({ fromAsset, amount, fromAddress, destinationAsset, destinationAddress, affiliateAddress, interfaceID, affiliateBps, toleranceBps, wallet, walletIndex, }: AmmEstimateSwapParams): Promise<TxDetails>;
31
31
  /**
32
32
  * Conducts a swap with the given inputs. Should be called after estimateSwap() to ensure the swap is valid
33
33
  *
package/lib/types.d.ts CHANGED
@@ -9,16 +9,14 @@ export type AllBalances = {
9
9
  export type ExecuteSwap = {
10
10
  input: CryptoAmount;
11
11
  destinationAsset: Asset;
12
- destinationAddress: Address;
12
+ destinationAddress?: Address;
13
13
  memo: string;
14
14
  feeOption?: FeeOption;
15
- waitTimeSeconds: number;
16
15
  walletIndex: number;
17
16
  };
18
17
  export type TxSubmitted = {
19
18
  hash: string;
20
19
  url: string;
21
- waitTimeSeconds: number;
22
20
  };
23
21
  export type LiquidityPosition = {
24
22
  assetPool: LiquidityPool;
package/lib/wallet.d.ts CHANGED
@@ -71,7 +71,7 @@ export declare class Wallet {
71
71
  * @param waitTimeSeconds - expected wait for the transaction to be processed
72
72
  * @returns
73
73
  */
74
- addSavers(assetAmount: CryptoAmount, memo: string, toAddress: Address, waitTimeSeconds: number): Promise<TxSubmitted>;
74
+ addSavers(assetAmount: CryptoAmount, memo: string, toAddress: Address): Promise<TxSubmitted>;
75
75
  /**
76
76
  *
77
77
  * @param assetAmount - amount to withdraw
@@ -79,7 +79,7 @@ export declare class Wallet {
79
79
  * @param waitTimeSeconds - expected wait for the transaction to be processed
80
80
  * @returns
81
81
  */
82
- withdrawSavers(dustAssetAmount: CryptoAmount, memo: string, toAddress: Address, waitTimeSeconds: number): Promise<TxSubmitted>;
82
+ withdrawSavers(dustAssetAmount: CryptoAmount, memo: string, toAddress: Address): Promise<TxSubmitted>;
83
83
  /** Function handles liquidity add for all non rune assets
84
84
  *
85
85
  * @param params - parameters for add liquidity
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-thorchain-amm",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "module that exposes estimating & swappping cryptocurrency assets on thorchain",
5
5
  "keywords": [
6
6
  "THORChain",
@@ -53,7 +53,7 @@
53
53
  "@xchainjs/xchain-litecoin": "^0.12.0",
54
54
  "@xchainjs/xchain-midgard": "^0.5.0",
55
55
  "@xchainjs/xchain-thorchain": "^0.28.0",
56
- "@xchainjs/xchain-thorchain-query": "^0.3.0",
56
+ "@xchainjs/xchain-thorchain-query": "^0.4.0",
57
57
  "@xchainjs/xchain-thornode": "^0.3.0",
58
58
  "@xchainjs/xchain-util": "^0.13.0",
59
59
  "@xchainjs/xchain-utxo-providers": "^0.2.0",
@@ -88,7 +88,7 @@
88
88
  "@xchainjs/xchain-litecoin": "^0.12.0",
89
89
  "@xchainjs/xchain-midgard": "^0.5.0",
90
90
  "@xchainjs/xchain-thorchain": "^0.28.0",
91
- "@xchainjs/xchain-thorchain-query": "^0.3.0",
91
+ "@xchainjs/xchain-thorchain-query": "^0.4.0",
92
92
  "@xchainjs/xchain-thornode": "^0.3.0",
93
93
  "@xchainjs/xchain-util": "^0.13.0",
94
94
  "@xchainjs/xchain-utxo-providers": "^0.2.0",