Skip to content

Commit f0ec486

Browse files
committed
trigger change when spend limit is topped up, add more logging
1 parent d448bdc commit f0ec486

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

eibc/lp.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type rollappCriteria struct {
3434
MinFeePercentage sdk.Dec
3535
OperatorFeeShare sdk.Dec
3636
SettlementValidated bool
37+
spendLimit sdk.Coins // keep private to exclude from hash, as spendLimit decreases as orders are fulfilled
3738
}
3839

3940
func (l *lp) hasBalance(amount sdk.Coins) bool {
@@ -131,6 +132,7 @@ func (or *orderTracker) loadLPs(ctx context.Context) error {
131132

132133
for _, grant := range grants.Grants {
133134
if grant.Authorization == nil {
135+
or.logger.Error("nil authorization", zap.Any("grant", grant))
134136
continue
135137
}
136138

@@ -157,13 +159,17 @@ func (or *orderTracker) loadLPs(ctx context.Context) error {
157159
balance: resp.Balances,
158160
}
159161

162+
l, existLP := or.lps[grant.Granter]
163+
160164
for _, rollapp := range g.Rollapps {
161165
// check if the rollapp is supported
162166
if !or.isRollappSupported(rollapp.RollappId) {
167+
or.logger.Debug("unsupported rollapp", zap.String("rollapp", rollapp.RollappId))
163168
continue
164169
}
165170
// check the operator fee is the minimum for what the operator wants
166171
if rollapp.OperatorFeeShare.Dec.LT(or.minOperatorFeeShare) {
172+
or.logger.Debug("operator fee share too low", zap.String("rollapp", rollapp.RollappId))
167173
continue
168174
}
169175

@@ -175,26 +181,32 @@ func (or *orderTracker) loadLPs(ctx context.Context) error {
175181
RollappID: rollapp.RollappId,
176182
Denoms: denoms,
177183
MaxPrice: rollapp.MaxPrice,
184+
spendLimit: rollapp.SpendLimit,
178185
MinFeePercentage: rollapp.MinFeePercentage.Dec,
179186
OperatorFeeShare: rollapp.OperatorFeeShare.Dec,
180187
SettlementValidated: rollapp.SettlementValidated,
181188
}
189+
if existLP {
190+
r, existRA := l.Rollapps[rollapp.RollappId]
191+
lpsUpdated = existRA && rollapp.SpendLimit.IsAnyGT(r.spendLimit)
192+
}
182193
}
183194

184195
if len(lp.Rollapps) == 0 {
196+
or.logger.Debug("no supported rollapps, skipping LP", zap.String("address", grant.Granter))
185197
continue
186198
}
187199

188200
lp.setHash()
189201

190-
l, ok := or.lps[grant.Granter]
191-
if ok {
202+
if existLP {
192203
if l.hash != lp.hash {
193204
or.logger.Info("LP updated", zap.String("address", grant.Granter))
194205
lpsUpdated = true
195206
}
196207
} else {
197208
or.logger.Info("LP added", zap.String("address", grant.Granter))
209+
lpsUpdated = true
198210
}
199211

200212
or.lps[grant.Granter] = lp

eibc/order_tracker.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func newOrderTracker(
7878
validation: validation,
7979
validOrdersCh: make(chan []*demandOrder),
8080
outputOrdersCh: ordersCh,
81-
logger: logger.With(zap.String("module", "order-resolver")),
81+
logger: logger.With(zap.String("module", "order-tracker")),
8282
subscriberID: subscriberID,
8383
balanceRefreshInterval: balanceRefreshInterval,
8484
validateOrdersInterval: validateOrdersInterval,

0 commit comments

Comments
 (0)