From 2f3ca6d865f3e71a93481acd86662a0d2ba7774c Mon Sep 17 00:00:00 2001 From: Hanjun Kim Date: Mon, 20 Jun 2022 15:12:37 +0900 Subject: [PATCH] fix: remove MatchRecord --- x/liquidity/amm/match.go | 10 ---------- x/liquidity/amm/order.go | 13 ++----------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/x/liquidity/amm/match.go b/x/liquidity/amm/match.go index 7d52e7ab..c3a15ec0 100644 --- a/x/liquidity/amm/match.go +++ b/x/liquidity/amm/match.go @@ -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) @@ -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 } diff --git a/x/liquidity/amm/order.go b/x/liquidity/amm/order.go index 737ad7fb..eb89500c 100644 --- a/x/liquidity/amm/order.go +++ b/x/liquidity/amm/order.go @@ -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 { @@ -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. @@ -78,7 +78,6 @@ type BaseOrder struct { OpenAmount sdk.Int PaidOfferCoinAmount sdk.Int ReceivedDemandCoinAmount sdk.Int - MatchRecords []MatchRecord } // NewBaseOrder returns a new BaseOrder. @@ -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) }