forked from stellar-deprecated/kelp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deleteSideStrategy.go
59 lines (50 loc) · 1.68 KB
/
deleteSideStrategy.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
package plugins
import (
"log"
"github.com/lightyeario/kelp/api"
"github.com/lightyeario/kelp/model"
"github.com/stellar/go/build"
"github.com/stellar/go/clients/horizon"
)
// deleteSideStrategy is a sideStrategy to delete the orders for a given currency pair on one side of the orderbook
type deleteSideStrategy struct {
sdex *SDEX
assetBase *horizon.Asset
assetQuote *horizon.Asset
}
// ensure it implements SideStrategy
var _ api.SideStrategy = &deleteSideStrategy{}
// makeDeleteSideStrategy is a factory method for deleteSideStrategy
func makeDeleteSideStrategy(
sdex *SDEX,
assetBase *horizon.Asset,
assetQuote *horizon.Asset,
) api.SideStrategy {
return &deleteSideStrategy{
sdex: sdex,
assetBase: assetBase,
assetQuote: assetQuote,
}
}
// PruneExistingOffers impl
func (s *deleteSideStrategy) PruneExistingOffers(offers []horizon.Offer) ([]build.TransactionMutator, []horizon.Offer) {
log.Printf("deleteSideStrategy: deleting %d offers\n", len(offers))
pruneOps := []build.TransactionMutator{}
for i := 0; i < len(offers); i++ {
pOp := s.sdex.DeleteOffer(offers[i])
pruneOps = append(pruneOps, &pOp)
}
return pruneOps, []horizon.Offer{}
}
// PreUpdate impl
func (s *deleteSideStrategy) PreUpdate(maxAssetBase float64, maxAssetQuote float64, trustBase float64, trustQuote float64, buyingAOffers []horizon.Offer, sellingAOffers []horizon.Offer) error {
return nil
}
// UpdateWithOps impl
func (s *deleteSideStrategy) UpdateWithOps(offers []horizon.Offer) (ops []build.TransactionMutator, newTopOffer *model.Number, e error) {
return []build.TransactionMutator{}, nil, nil
}
// PostUpdate impl
func (s *deleteSideStrategy) PostUpdate() error {
return nil
}