Skip to content

Commit

Permalink
fix: remove MatchRecord
Browse files Browse the repository at this point in the history
  • Loading branch information
hallazzang committed Jun 20, 2022
1 parent 383d8b9 commit 2f3ca6d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
10 changes: 0 additions & 10 deletions x/liquidity/amm/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ func (dir PriceDirection) String() string {
}
}

// MatchRecord holds a single match record.
type MatchRecord struct {
Amount sdk.Int
Price sdk.Dec
}

// FillOrder fills the order by given amount and price.
func FillOrder(order Order, amt sdk.Int, price sdk.Dec) (quoteCoinDiff sdk.Int) {
matchableAmt := MatchableAmount(order, price)
Expand All @@ -55,10 +49,6 @@ func FillOrder(order Order, amt sdk.Int, price sdk.Dec) (quoteCoinDiff sdk.Int)
order.SetPaidOfferCoinAmount(order.GetPaidOfferCoinAmount().Add(paid))
order.SetReceivedDemandCoinAmount(order.GetReceivedDemandCoinAmount().Add(received))
order.SetOpenAmount(order.GetOpenAmount().Sub(amt))
order.AddMatchRecord(MatchRecord{
Amount: amt,
Price: price,
})
return
}

Expand Down
13 changes: 2 additions & 11 deletions x/liquidity/amm/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type Orderer interface {
Order(dir OrderDirection, price sdk.Dec, amt sdk.Int) Order
}

// BaseOrderer creates new BaseOrder with sufficient offer coin amount
// considering price and amount.
type BaseOrderer struct{}

func (orderer BaseOrderer) Order(dir OrderDirection, price sdk.Dec, amt sdk.Int) Order {
Expand All @@ -58,8 +60,6 @@ type Order interface {
SetReceivedDemandCoinAmount(amt sdk.Int)
GetOpenAmount() sdk.Int
SetOpenAmount(amt sdk.Int)
GetMatchRecords() []MatchRecord // TODO: remove
AddMatchRecord(record MatchRecord) // TODO: remove
IsMatched() bool
// HasPriority returns true if the order has higher priority
// than the other order.
Expand All @@ -78,7 +78,6 @@ type BaseOrder struct {
OpenAmount sdk.Int
PaidOfferCoinAmount sdk.Int
ReceivedDemandCoinAmount sdk.Int
MatchRecords []MatchRecord
}

// NewBaseOrder returns a new BaseOrder.
Expand Down Expand Up @@ -141,14 +140,6 @@ func (order *BaseOrder) SetOpenAmount(amt sdk.Int) {
order.OpenAmount = amt
}

func (order *BaseOrder) GetMatchRecords() []MatchRecord {
return order.MatchRecords
}

func (order *BaseOrder) AddMatchRecord(record MatchRecord) {
order.MatchRecords = append(order.MatchRecords, record)
}

func (order *BaseOrder) IsMatched() bool {
return order.OpenAmount.LT(order.Amount)
}
Expand Down

0 comments on commit 2f3ca6d

Please sign in to comment.