diff --git a/ocp/worker/currency/feeburner/worker.go b/ocp/worker/currency/feeburner/worker.go index eff6238..9527947 100644 --- a/ocp/worker/currency/feeburner/worker.go +++ b/ocp/worker/currency/feeburner/worker.go @@ -58,6 +58,20 @@ func (p *runtime) sweep(runtimeCtx context.Context) error { ).Warn("skipping currency with invalid metadata") continue } + + hasFees, err := p.hasFeesToBurn(tracedCtx, item) + if err != nil { + trace.OnError(err) + p.log.With( + zap.Error(err), + zap.String("mint", item.Mint), + ).Warn("failure checking for fees to burn") + continue + } + if !hasFees { + continue + } + targets = append(targets, target) } @@ -101,6 +115,23 @@ func (p *runtime) makeBurnTarget(record *currency.MetadataRecord) (*burnTarget, }, nil } +func (p *runtime) hasFeesToBurn(ctx context.Context, record *currency.MetadataRecord) (bool, error) { + ai, _, err := p.data.GetBlockchainAccountInfo(ctx, record.LiquidityPool, solana.CommitmentFinalized) + if err == solana.ErrNoAccountInfo { + return false, nil + } else if err != nil { + return false, errors.Wrap(err, "error getting liquidity pool account info") + } + + var pool currencycreator.LiquidityPoolAccount + err = pool.Unmarshal(ai.Data) + if err != nil { + return false, errors.Wrap(err, "invalid liquidity pool account data") + } + + return pool.FeesAccumulated > 0, nil +} + // packBurnBatches greedily packs burn targets into the fewest transactions // that fit within the transaction size limit. func (p *runtime) packBurnBatches(targets []*burnTarget) [][]*burnTarget {