code.vegaprotocol.io/vega@v0.79.0/core/events/volume_rebate_program.go (about)

     1  // Copyright (C) 2023 Gobalsky Labs Limited
     2  //
     3  // This program is free software: you can redistribute it and/or modify
     4  // it under the terms of the GNU Affero General Public License as
     5  // published by the Free Software Foundation, either version 3 of the
     6  // License, or (at your option) any later version.
     7  //
     8  // This program is distributed in the hope that it will be useful,
     9  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    10  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11  // GNU Affero General Public License for more details.
    12  //
    13  // You should have received a copy of the GNU Affero General Public License
    14  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    15  
    16  package events
    17  
    18  import (
    19  	"context"
    20  	"time"
    21  
    22  	"code.vegaprotocol.io/vega/core/types"
    23  	"code.vegaprotocol.io/vega/libs/ptr"
    24  	eventspb "code.vegaprotocol.io/vega/protos/vega/events/v1"
    25  )
    26  
    27  type VolumeRebateProgramStarted struct {
    28  	*Base
    29  	e *eventspb.VolumeRebateProgramStarted
    30  }
    31  
    32  func (v *VolumeRebateProgramStarted) GetVolumeRebateProgramStarted() *eventspb.VolumeRebateProgramStarted {
    33  	return v.e
    34  }
    35  
    36  func (t *VolumeRebateProgramStarted) StreamMessage() *eventspb.BusEvent {
    37  	busEvent := newBusEventFromBase(t.Base)
    38  	busEvent.Event = &eventspb.BusEvent_VolumeRebateProgramStarted{
    39  		VolumeRebateProgramStarted: t.e,
    40  	}
    41  
    42  	return busEvent
    43  }
    44  
    45  func NewVolumeRebateProgramStartedEvent(ctx context.Context, p *types.VolumeRebateProgram, epochTime time.Time, epoch uint64) *VolumeRebateProgramStarted {
    46  	return &VolumeRebateProgramStarted{
    47  		Base: newBase(ctx, VolumeRebateProgramStartedEvent),
    48  		e: &eventspb.VolumeRebateProgramStarted{
    49  			Program:   p.IntoProto(),
    50  			StartedAt: epochTime.UnixNano(),
    51  			AtEpoch:   epoch,
    52  		},
    53  	}
    54  }
    55  
    56  func VolumeRebateProgramStartedEventFromStream(ctx context.Context, be *eventspb.BusEvent) *VolumeRebateProgramStarted {
    57  	return &VolumeRebateProgramStarted{
    58  		Base: newBaseFromBusEvent(ctx, VolumeRebateProgramStartedEvent, be),
    59  		e:    be.GetVolumeRebateProgramStarted(),
    60  	}
    61  }
    62  
    63  type VolumeRebateProgramUpdated struct {
    64  	*Base
    65  	e *eventspb.VolumeRebateProgramUpdated
    66  }
    67  
    68  func (v *VolumeRebateProgramUpdated) GetVolumeRebateProgramUpdated() *eventspb.VolumeRebateProgramUpdated {
    69  	return v.e
    70  }
    71  
    72  func (t *VolumeRebateProgramUpdated) StreamMessage() *eventspb.BusEvent {
    73  	busEvent := newBusEventFromBase(t.Base)
    74  	busEvent.Event = &eventspb.BusEvent_VolumeRebateProgramUpdated{
    75  		VolumeRebateProgramUpdated: t.e,
    76  	}
    77  
    78  	return busEvent
    79  }
    80  
    81  func NewVolumeRebateProgramUpdatedEvent(ctx context.Context, p *types.VolumeRebateProgram, epochTime time.Time, epoch uint64) *VolumeRebateProgramUpdated {
    82  	return &VolumeRebateProgramUpdated{
    83  		Base: newBase(ctx, VolumeRebateProgramUpdatedEvent),
    84  		e: &eventspb.VolumeRebateProgramUpdated{
    85  			Program:   p.IntoProto(),
    86  			UpdatedAt: epochTime.UnixNano(),
    87  			AtEpoch:   epoch,
    88  		},
    89  	}
    90  }
    91  
    92  func VolumeRebateProgramUpdatedEventFromStream(ctx context.Context, be *eventspb.BusEvent) *VolumeRebateProgramUpdated {
    93  	return &VolumeRebateProgramUpdated{
    94  		Base: newBaseFromBusEvent(ctx, VolumeRebateProgramUpdatedEvent, be),
    95  		e:    be.GetVolumeRebateProgramUpdated(),
    96  	}
    97  }
    98  
    99  type VolumeRebateProgramEnded struct {
   100  	*Base
   101  	e *eventspb.VolumeRebateProgramEnded
   102  }
   103  
   104  func (v *VolumeRebateProgramEnded) GetVolumeRebateProgramEnded() *eventspb.VolumeRebateProgramEnded {
   105  	return v.e
   106  }
   107  
   108  func (t *VolumeRebateProgramEnded) StreamMessage() *eventspb.BusEvent {
   109  	busEvent := newBusEventFromBase(t.Base)
   110  	busEvent.Event = &eventspb.BusEvent_VolumeRebateProgramEnded{
   111  		VolumeRebateProgramEnded: t.e,
   112  	}
   113  
   114  	return busEvent
   115  }
   116  
   117  func NewVolumeRebateProgramEndedEvent(ctx context.Context, version uint64, id string, epochTime time.Time, epoch uint64) *VolumeRebateProgramEnded {
   118  	return &VolumeRebateProgramEnded{
   119  		Base: newBase(ctx, VolumeRebateProgramEndedEvent),
   120  		e: &eventspb.VolumeRebateProgramEnded{
   121  			Version: version,
   122  			Id:      id,
   123  			EndedAt: epochTime.UnixNano(),
   124  			AtEpoch: epoch,
   125  		},
   126  	}
   127  }
   128  
   129  func VolumeRebateProgramEndedEventFromStream(ctx context.Context, be *eventspb.BusEvent) *VolumeRebateProgramEnded {
   130  	return &VolumeRebateProgramEnded{
   131  		Base: newBaseFromBusEvent(ctx, VolumeRebateProgramEndedEvent, be),
   132  		e:    be.GetVolumeRebateProgramEnded(),
   133  	}
   134  }
   135  
   136  type VolumeRebateStatsUpdated struct {
   137  	*Base
   138  	vdsu eventspb.VolumeRebateStatsUpdated
   139  }
   140  
   141  func NewVolumeRebateStatsUpdatedEvent(ctx context.Context, vdsu *eventspb.VolumeRebateStatsUpdated) *VolumeRebateStatsUpdated {
   142  	order := &VolumeRebateStatsUpdated{
   143  		Base: newBase(ctx, VolumeRebateStatsUpdatedEvent),
   144  		vdsu: *vdsu,
   145  	}
   146  	return order
   147  }
   148  
   149  func (p *VolumeRebateStatsUpdated) VolumeRebateStatsUpdated() *eventspb.VolumeRebateStatsUpdated {
   150  	return ptr.From(p.vdsu)
   151  }
   152  
   153  func (p VolumeRebateStatsUpdated) Proto() eventspb.VolumeRebateStatsUpdated {
   154  	return p.vdsu
   155  }
   156  
   157  func (p VolumeRebateStatsUpdated) StreamMessage() *eventspb.BusEvent {
   158  	busEvent := newBusEventFromBase(p.Base)
   159  	busEvent.Event = &eventspb.BusEvent_VolumeRebateStatsUpdated{
   160  		VolumeRebateStatsUpdated: ptr.From(p.vdsu),
   161  	}
   162  
   163  	return busEvent
   164  }
   165  
   166  func VolumeRebateStatsUpdatedEventFromStream(ctx context.Context, be *eventspb.BusEvent) *VolumeRebateStatsUpdated {
   167  	order := &VolumeRebateStatsUpdated{
   168  		Base: newBaseFromBusEvent(ctx, VolumeRebateStatsUpdatedEvent, be),
   169  		vdsu: ptr.UnBox(be.GetVolumeRebateStatsUpdated()),
   170  	}
   171  	return order
   172  }