Skip to content

Commit

Permalink
Simplify the Offer data model as a part of cut-1
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikiyer56 committed Nov 15, 2024
1 parent 4ac02e6 commit 2864e8d
Showing 1 changed file with 2 additions and 39 deletions.
41 changes: 2 additions & 39 deletions ingest/offers/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type OfferEventData struct {

type OfferEvent interface {
OfferEventType() string
GetOfferData() OfferEventData
}

type OfferCreatedEvent struct {
Expand All @@ -47,8 +46,7 @@ func (e OfferCreatedEvent) OfferEventType() string { return EventTypeOfferCreate

type OfferFillEvent struct {
OfferEventData
FillAmount int64
MatchingOrders []OfferFill
FillAmount int64 // How much amount of the order was filled from last time
}

func (e OfferFillEvent) OfferEventType() string { return EventTypeOfferFill }
Expand All @@ -60,41 +58,6 @@ type OfferClosedEvent struct {

func (e OfferClosedEvent) OfferEventType() string { return EventTypeOfferClosed }

type OfferFillInfo struct {
AssetSold xdr.Asset
AmountSold int64
AssetBought xdr.Asset
AmountBought int64
}

type OfferFill interface {
OfferClaimantType() string
}

type LiquidityPoolClaimant struct {
PoolId xdr.PoolId
*OfferFillInfo
}

type OrderBookClaimant struct {
SellerId xdr.AccountId
OfferId int64
*OfferFillInfo
}

const (
OrderBookClaimantType = "OrderBookClaimant"
LiquidityPoolClaimantType = "LiquidityPoolClaimant"
)

func (o *LiquidityPoolClaimant) OfferClaimantType() string {
return LiquidityPoolClaimantType
}

func (o *OrderBookClaimant) OfferClaimantType() string {
return OrderBookClaimantType
}

func populateOfferData(e *xdr.LedgerEntry) OfferEventData {
offer := e.Data.MustOffer()
return OfferEventData{
Expand Down Expand Up @@ -140,6 +103,6 @@ func ProcessOffer(change ingest.Change) OfferEvent {
event = OfferClosedEvent{OfferEventData: o}
//TODO: populate CloseReason field in OfferClosedEvent
}
return event

return event
}

0 comments on commit 2864e8d

Please sign in to comment.