Skip to content

Commit

Permalink
integrate new abacus launch incentives fields
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-dydx committed Feb 21, 2024
1 parent 5c8aaea commit f72d09d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import dydxStateManager
import dydxFormatter
import Utilities
import Abacus
import RoutingKit

public protocol dydxRewardsLaunchIncentivesPresenterProtocol: HostedViewPresenterProtocol {
var viewModel: dydxRewardsLaunchIncentivesViewModel? { get }
Expand All @@ -37,14 +38,12 @@ public class dydxRewardsLaunchIncentivesPresenter: HostedViewPresenter<dydxRewar

}
.store(in: &subscriptions)



viewModel.aboutAction = {
viewModel?.aboutAction = {
Router.shared?.navigate(to: URL(string: "https://dydx.exchange/blog/v4-full-trading"), completion: nil)
}
viewModel.leaderboardAction = {

viewModel?.leaderboardAction = {
Router.shared?.navigate(to: URL(string: "https://community.chaoslabs.xyz/dydx-v4/risk/leaderboard"), completion: nil)
}
}
Expand All @@ -55,8 +54,8 @@ public class dydxRewardsLaunchIncentivesPresenter: HostedViewPresenter<dydxRewar
viewModel?.estimatedPoints = "\(points)"
viewModel?.points = "\(points)"
} else {
viewModel?.estimatedPoints = nil
viewModel?.points = nil
viewModel?.estimatedPoints = "--"
viewModel?.points = "--"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ private class dydxTradingRewardsViewPresenter: HostedViewPresenter<dydxTradingRe
private let historyPresenter = dydxRewardsHistoryViewPresenter()

private lazy var childPresenters: [HostedViewPresenterProtocol] = [
launchIncentivesPresenter,
summaryPresenter,
helpPresenter,
historyPresenter
Expand Down Expand Up @@ -72,7 +73,7 @@ private class dydxTradingRewardsViewPresenter: HostedViewPresenter<dydxTradingRe
// Router.shared?.navigate (to: , completion: nil)
// }

launchIncentivesPresenter.$viewModel.assign(to: &viewModel.launchIncentivesViewModel)
launchIncentivesPresenter.$viewModel.assign(to: &viewModel.$launchIncentivesViewModel)
summaryPresenter.$viewModel.assign(to: &viewModel.$rewardsSummary)
helpPresenter.$viewModel.assign(to: &viewModel.$help)
historyPresenter.$viewModel.assign(to: &viewModel.$history)
Expand All @@ -87,17 +88,4 @@ private class dydxTradingRewardsViewPresenter: HostedViewPresenter<dydxTradingRe

attachChildren(workers: childPresenters)
}

override func start() {
super.start()

AbacusStateManager.shared.state.account
.sink { [weak self] _ in
// TODO: get from chaos labs
self?.viewModel?.launchIncentivesViewModel.seasonOrdinal = "--"
self?.viewModel?.launchIncentivesViewModel.estimatedPoints = "--"
self?.viewModel?.launchIncentivesViewModel.points = "--"
}
.store(in: &subscriptions)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
02E7DC6028CFAF5C00727949 /* dydxStateManager */ = {
isa = PBXGroup;
children = (
6473ACAC2A65B17500BBC01F /* Protocol Implementations */,
6473ACAC2A65B17500BBC01F /* Protocol_Implementations */,
02603B8D29F1A53500DFFD11 /* ClientStates */,
020EB67D299C0C1F00E8026B /* Transactions */,
02E7DD8428CFB1C600727949 /* network */,
Expand Down Expand Up @@ -324,7 +324,7 @@
path = network;
sourceTree = "<group>";
};
6473ACAC2A65B17500BBC01F /* Protocol Implementations */ = {
6473ACAC2A65B17500BBC01F /* Protocol_Implementations */ = {
isa = PBXGroup;
children = (
6473ACB32A65B18B00BBC01F /* AbacusRestImp.swift */,
Expand All @@ -338,7 +338,7 @@
646EE0842A75A8F4006A68E4 /* AbacusTimerImp.swift */,
646EDDEE2A732DBB006A68E4 /* Implementations.swift */,
);
path = "Protocol Implementations";
path = Protocol_Implementations;
sourceTree = "<group>";
};
6478FC0F296DEF7400654C56 /* Products */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public class dydxRewardsLaunchIncentivesViewModel: PlatformViewModel {
}
.wrappedInAnyView()
}
return PlatformButtonViewModel(content: content, type: .defaultType, state: .primary, action: self.aboutAction ?? {})
return PlatformButtonViewModel(content: content, type: .defaultType, state: .primary, action: self.leaderboardAction ?? {})
.createView(parentStyle: parentStyle)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Utilities
public class dydxTradingRewardsViewModel: PlatformViewModel {

@Published public var headerViewModel: NavHeaderModel = NavHeaderModel()
@Published public var launchIncentivesViewModel: dydxRewardsLaunchIncentivesViewModel = dydxRewardsLaunchIncentivesViewModel()
@Published public var launchIncentivesViewModel: dydxRewardsLaunchIncentivesViewModel? = dydxRewardsLaunchIncentivesViewModel()
@Published public var rewardsSummary: dydxRewardsSummaryViewModel? = dydxRewardsSummaryViewModel()
@Published public var help: dydxRewardsHelpViewModel? = dydxRewardsHelpViewModel()
@Published public var history: dydxRewardsHistoryViewModel? = dydxRewardsHistoryViewModel()
Expand All @@ -36,7 +36,7 @@ public class dydxTradingRewardsViewModel: PlatformViewModel {
self.headerViewModel.createView(parentStyle: parentStyle)
ScrollView(showsIndicators: false) {
VStack(spacing: 16) {
self.launchIncentivesViewModel.createView(parentStyle: style)
self.launchIncentivesViewModel?.createView(parentStyle: style)
self.rewardsSummary?.createView(parentStyle: style)
self.help?.createView(parentStyle: style)
self.history?.createView(parentStyle: style)
Expand Down

0 comments on commit f72d09d

Please sign in to comment.