Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions ocp/worker/currency/feeburner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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 {
Expand Down
Loading