-
Notifications
You must be signed in to change notification settings - Fork 22
/
convert.go
202 lines (196 loc) · 10.6 KB
/
convert.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
// Copyright (C) 2023 Gobalsky Labs Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Copyright (c) 2022 Gobalsky Labs Limited
//
// Use of this software is governed by the Business Source License included
// in the LICENSE.DATANODE file and at https://www.mariadb.com/bsl11.
//
// Change Date: 18 months from the later of the date of the first publicly
// available Distribution of this version of the repository, and 25 June 2022.
//
// On the date above, in accordance with the Business Source License, use
// of this software will be governed by version 3 or later of the GNU General
// Public License.
package broker
import (
"context"
"code.vegaprotocol.io/vega/core/events"
eventspb "code.vegaprotocol.io/vega/protos/vega/events/v1"
)
func toEvent(ctx context.Context, be *eventspb.BusEvent) events.Event {
switch be.Type {
case eventspb.BusEventType_BUS_EVENT_TYPE_TIME_UPDATE:
return events.TimeEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_LEDGER_MOVEMENTS:
return events.TransferResponseEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_POSITION_RESOLUTION:
return events.PositionResolutionEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_ORDER:
return events.OrderEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_ACCOUNT:
return events.AccountEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_PARTY:
return events.PartyEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_TRADE:
return events.TradeEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_MARGIN_LEVELS:
return events.MarginLevelsEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_PROPOSAL:
return events.ProposalEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_VOTE:
return events.VoteEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_MARKET_DATA:
return events.MarketDataEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_NODE_SIGNATURE:
return events.NodeSignatureEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_LOSS_SOCIALIZATION:
return events.LossSocializationEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_SETTLE_POSITION:
return events.SettlePositionEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_SETTLE_DISTRESSED:
return events.SettleDistressedEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_MARKET_CREATED:
return events.MarketCreatedEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_ASSET:
return events.AssetEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_MARKET_TICK:
return events.MarketTickEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_WITHDRAWAL:
return events.WithdrawalEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_DEPOSIT:
return events.DepositEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_AUCTION:
return events.AuctionEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_RISK_FACTOR:
return events.RiskFactorEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_NETWORK_PARAMETER:
return events.NetworkParameterEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_LIQUIDITY_PROVISION:
return events.LiquidityProvisionEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_MARKET_UPDATED:
return events.MarketUpdatedEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_ORACLE_SPEC:
return events.OracleSpecEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_ORACLE_DATA:
return events.OracleDataEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_TX_ERROR:
return events.TxErrEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_EPOCH_UPDATE:
return events.EpochEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_DELEGATION_BALANCE:
return events.DelegationBalanceEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_VALIDATOR_UPDATE:
return events.ValidatorUpdateEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_REWARD_PAYOUT_EVENT:
return events.RewardPayoutEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_STAKE_LINKING:
return events.StakeLinkingFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_VALIDATOR_SCORE:
return events.ValidatorScoreEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_CHECKPOINT:
return events.CheckpointEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_KEY_ROTATION:
return events.KeyRotationEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_STATE_VAR:
return events.StateVarEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_NETWORK_LIMITS:
return events.NetworkLimitsEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_TRANSFER:
return events.TransferFundsEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_VALIDATOR_RANKING:
return events.ValidatorRankingEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_ERC20_MULTI_SIG_SET_THRESHOLD:
return events.ERC20MultiSigThresholdSetFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_ERC20_MULTI_SIG_SIGNER_EVENT:
return events.ERC20MultiSigSignerFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_ERC20_MULTI_SIG_SIGNER_ADDED:
return events.ERC20MultiSigSignerAddedFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_ERC20_MULTI_SIG_SIGNER_REMOVED:
return events.ERC20MultiSigSignerRemovedFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_POSITION_STATE:
return events.PositionStateEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_ETHEREUM_KEY_ROTATION:
return events.EthereumKeyRotationEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_PROTOCOL_UPGRADE_PROPOSAL:
return events.ProtocolUpgradeProposalEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_BEGIN_BLOCK:
return events.BeginBlockEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_END_BLOCK:
return events.EndBlockEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_PROTOCOL_UPGRADE_STARTED:
return events.ProtocolUpgradeStartedEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_SETTLE_MARKET:
return events.SettleMarketEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_TRANSACTION_RESULT:
return events.TransactionResultEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_SNAPSHOT_TAKEN:
return events.SnapthostTakenEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_DISTRESSED_ORDERS_CLOSED:
return events.DistressedOrdersEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_EXPIRED_ORDERS:
return events.ExpiredOrdersEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_DISTRESSED_POSITIONS:
return events.DistressedPositionsEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_STOP_ORDER:
return events.StopOrderEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_FUNDING_PERIOD:
return events.FundingPeriodEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_FUNDING_PERIOD_DATA_POINT:
return events.FundingPeriodDataPointEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_TEAM_CREATED:
return events.TeamCreatedEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_TEAM_UPDATED:
return events.TeamUpdatedEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_REFEREE_SWITCHED_TEAM:
return events.RefereeSwitchedTeamEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_REFEREE_JOINED_TEAM:
return events.RefereeJoinedTeamEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_REFERRAL_PROGRAM_STARTED:
return events.ReferralProgramStartedEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_REFERRAL_PROGRAM_ENDED:
return events.ReferralProgramEndedEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_REFERRAL_PROGRAM_UPDATED:
return events.ReferralProgramUpdatedEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_REFERRAL_SET_CREATED:
return events.ReferralSetCreatedEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_REFEREE_JOINED_REFERRAL_SET:
return events.RefereeJoinedReferralSetEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_PARTY_ACTIVITY_STREAK:
return events.PartyActivityStreakEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_VOLUME_DISCOUNT_PROGRAM_STARTED:
return events.VolumeDiscountProgramStartedEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_VOLUME_DISCOUNT_PROGRAM_ENDED:
return events.VolumeDiscountProgramEndedEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_VOLUME_DISCOUNT_PROGRAM_UPDATED:
return events.VolumeDiscountProgramUpdatedEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_REFERRAL_SET_STATS_UPDATED:
return events.ReferralSetStatsUpdatedEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_VESTING_STATS_UPDATED:
return events.VestingStatsUpdatedEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_VOLUME_DISCOUNT_STATS_UPDATED:
return events.VolumeDiscountStatsUpdatedEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_FEES_STATS_UPDATED:
return events.FeesStatsEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_FUNDING_PAYMENTS:
return events.FundingPaymentEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_PAID_LIQUIDITY_FEES_STATS_UPDATED:
return events.PaidLiquidityFeesStatsEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_VESTING_SUMMARY:
return events.VestingBalancesSummaryEventFromStream(ctx, be)
case eventspb.BusEventType_BUS_EVENT_TYPE_TRANSFER_FEES_PAID:
return events.TransferFeesEventFromStream(ctx, be)
}
return nil
}