@@ -46,7 +46,8 @@ import {
46
46
NewTradingPoolV2Info ,
47
47
PerformanceFeeInfo ,
48
48
TradingPoolAccumulationInfo ,
49
- TradingPoolRebalanceInfo
49
+ TradingPoolRebalanceInfo ,
50
+ TradingPoolTWAPRebalanceInfo ,
50
51
} from '../types/strategies' ;
51
52
52
53
const { SetProtocolUtils : SetUtils } = setProtocolUtils ;
@@ -538,6 +539,23 @@ export class SocialTradingAPI {
538
539
return this . createTradingPoolRebalanceObject ( newPoolInfo ) ;
539
540
}
540
541
542
+ /**
543
+ * Returns relevant details of Trading Pools being rebalanced by TWAP. Return object adheres to the
544
+ * TradingPoolTWAPRebalanceInfo interface.
545
+ *
546
+ * @param tradingPool Address of tradingPool being updated
547
+ * @return NewTradingPoolInfo
548
+ */
549
+ public async fetchTradingPoolTWAPRebalanceDetailsAsync (
550
+ tradingPool : Address
551
+ ) : Promise < TradingPoolTWAPRebalanceInfo > {
552
+ const newPoolInfo = await this . protocolViewer . fetchTradingPoolTWAPRebalanceDetails (
553
+ tradingPool
554
+ ) ;
555
+
556
+ return this . createTradingPoolTWAPRebalanceObject ( newPoolInfo ) ;
557
+ }
558
+
541
559
/**
542
560
* Fetches all trading pool operators for an array of trading pools
543
561
*
@@ -701,18 +719,18 @@ export class SocialTradingAPI {
701
719
return {
702
720
trader : poolInfo . trader ,
703
721
allocator : poolInfo . allocator ,
704
- currentAllocation : poolInfo . currentAllocation ,
722
+ currentAllocation : new BigNumber ( poolInfo . currentAllocation ) ,
705
723
manager : rbSetInfo . manager ,
706
724
feeRecipient : rbSetInfo . feeRecipient ,
707
725
currentSet : rbSetInfo . currentSet ,
708
726
poolName : rbSetInfo . name ,
709
727
poolSymbol : rbSetInfo . symbol ,
710
- unitShares : rbSetInfo . unitShares ,
711
- naturalUnit : rbSetInfo . naturalUnit ,
712
- rebalanceInterval : rbSetInfo . rebalanceInterval ,
713
- entryFee : rbSetInfo . entryFee ,
714
- rebalanceFee : rbSetInfo . rebalanceFee ,
715
- lastRebalanceTimestamp : rbSetInfo . lastRebalanceTimestamp ,
728
+ unitShares : new BigNumber ( rbSetInfo . unitShares ) ,
729
+ naturalUnit : new BigNumber ( rbSetInfo . naturalUnit ) ,
730
+ rebalanceInterval : new BigNumber ( rbSetInfo . rebalanceInterval ) ,
731
+ entryFee : new BigNumber ( rbSetInfo . entryFee ) ,
732
+ rebalanceFee : new BigNumber ( rbSetInfo . rebalanceFee ) ,
733
+ lastRebalanceTimestamp : new BigNumber ( rbSetInfo . lastRebalanceTimestamp ) ,
716
734
rebalanceState : rbSetInfo . rebalanceState ,
717
735
currentSetInfo : collateralInfo ,
718
736
} as NewTradingPoolInfo ;
@@ -732,18 +750,18 @@ export class SocialTradingAPI {
732
750
return {
733
751
trader : poolInfo . trader ,
734
752
allocator : poolInfo . allocator ,
735
- currentAllocation : poolInfo . currentAllocation ,
753
+ currentAllocation : new BigNumber ( poolInfo . currentAllocation ) ,
736
754
manager : rbSetInfo . manager ,
737
755
feeRecipient : rbSetInfo . feeRecipient ,
738
756
currentSet : rbSetInfo . currentSet ,
739
757
poolName : rbSetInfo . name ,
740
758
poolSymbol : rbSetInfo . symbol ,
741
- unitShares : rbSetInfo . unitShares ,
742
- naturalUnit : rbSetInfo . naturalUnit ,
743
- rebalanceInterval : rbSetInfo . rebalanceInterval ,
744
- entryFee : rbSetInfo . entryFee ,
745
- rebalanceFee : rbSetInfo . rebalanceFee ,
746
- lastRebalanceTimestamp : rbSetInfo . lastRebalanceTimestamp ,
759
+ unitShares : new BigNumber ( rbSetInfo . unitShares ) ,
760
+ naturalUnit : new BigNumber ( rbSetInfo . naturalUnit ) ,
761
+ rebalanceInterval : new BigNumber ( rbSetInfo . rebalanceInterval ) ,
762
+ entryFee : new BigNumber ( rbSetInfo . entryFee ) ,
763
+ rebalanceFee : new BigNumber ( rbSetInfo . rebalanceFee ) ,
764
+ lastRebalanceTimestamp : new BigNumber ( rbSetInfo . lastRebalanceTimestamp ) ,
747
765
rebalanceState : rbSetInfo . rebalanceState ,
748
766
currentSetInfo : collateralInfo ,
749
767
performanceFeeInfo : perfFeeInfo ,
@@ -759,21 +777,50 @@ export class SocialTradingAPI {
759
777
return {
760
778
trader : poolInfo . trader ,
761
779
allocator : poolInfo . allocator ,
762
- currentAllocation : poolInfo . currentAllocation ,
780
+ currentAllocation : new BigNumber ( poolInfo . currentAllocation ) ,
763
781
liquidator : rbSetInfo . liquidator ,
764
782
nextSet : rbSetInfo . nextSet ,
765
- rebalanceStartTime : rbSetInfo . rebalanceStartTime ,
766
- timeToPivot : rbSetInfo . timeToPivot ,
767
- startPrice : rbSetInfo . startPrice ,
768
- endPrice : rbSetInfo . endPrice ,
769
- startingCurrentSets : rbSetInfo . startingCurrentSets ,
770
- remainingCurrentSets : rbSetInfo . remainingCurrentSets ,
771
- minimumBid : rbSetInfo . minimumBid ,
783
+ rebalanceStartTime : new BigNumber ( rbSetInfo . rebalanceStartTime ) ,
784
+ timeToPivot : new BigNumber ( rbSetInfo . timeToPivot ) ,
785
+ startPrice : new BigNumber ( rbSetInfo . startPrice ) ,
786
+ endPrice : new BigNumber ( rbSetInfo . endPrice ) ,
787
+ startingCurrentSets : new BigNumber ( rbSetInfo . startingCurrentSets ) ,
788
+ remainingCurrentSets : new BigNumber ( rbSetInfo . remainingCurrentSets ) ,
789
+ minimumBid : new BigNumber ( rbSetInfo . minimumBid ) ,
772
790
rebalanceState : rbSetInfo . rebalanceState ,
773
791
nextSetInfo : collateralInfo ,
774
792
} as TradingPoolRebalanceInfo ;
775
793
}
776
794
795
+ private createTradingPoolTWAPRebalanceObject (
796
+ newPoolInfo : any ,
797
+ ) : TradingPoolTWAPRebalanceInfo {
798
+ const [ poolInfo , rbSetInfo , collateralInfo ] = newPoolInfo ;
799
+
800
+ return {
801
+ trader : poolInfo . trader ,
802
+ allocator : poolInfo . allocator ,
803
+ currentAllocation : new BigNumber ( poolInfo . currentAllocation ) ,
804
+ liquidator : rbSetInfo . liquidator ,
805
+ nextSet : rbSetInfo . nextSet ,
806
+ rebalanceStartTime : new BigNumber ( rbSetInfo . rebalanceStartTime ) ,
807
+ timeToPivot : new BigNumber ( rbSetInfo . timeToPivot ) ,
808
+ startPrice : new BigNumber ( rbSetInfo . startPrice ) ,
809
+ endPrice : new BigNumber ( rbSetInfo . endPrice ) ,
810
+ startingCurrentSets : new BigNumber ( rbSetInfo . startingCurrentSets ) ,
811
+ remainingCurrentSets : new BigNumber ( rbSetInfo . remainingCurrentSets ) ,
812
+ minimumBid : new BigNumber ( rbSetInfo . minimumBid ) ,
813
+ orderSize : new BigNumber ( rbSetInfo . orderSize ) ,
814
+ orderRemaining : new BigNumber ( rbSetInfo . orderRemaining ) ,
815
+ totalSetsRemaining : new BigNumber ( rbSetInfo . totalSetsRemaining ) ,
816
+ chunkSize : new BigNumber ( rbSetInfo . chunkSize ) ,
817
+ chunkAuctionPeriod : new BigNumber ( rbSetInfo . chunkAuctionPeriod ) ,
818
+ lastChunkAuctionEnd : new BigNumber ( rbSetInfo . lastChunkAuctionEnd ) ,
819
+ rebalanceState : rbSetInfo . rebalanceState ,
820
+ nextSetInfo : collateralInfo ,
821
+ } as TradingPoolTWAPRebalanceInfo ;
822
+ }
823
+
777
824
private createTradingPoolAccumulationObject (
778
825
tradingPoolFees : any ,
779
826
) : TradingPoolAccumulationInfo [ ] {
0 commit comments