store the filtered vouchers from the GetPoolSwappableFromVouchers

This commit is contained in:
Alfred Kamanda 2026-01-29 17:10:20 +03:00
parent 0a69e04229
commit ead5dd7b8c
Signed by: Alfred-mk
GPG Key ID: E60B2165A97F4D41

View File

@ -176,6 +176,19 @@ func (h *MenuHandlers) CalculateCreditAndDebt(ctx context.Context, sym string, i
return res, nil
}
// Filter out the active voucher from swappableVouchers
filteredSwappableVouchers := make([]dataserviceapi.TokenHoldings, 0, len(swappableVouchers))
for _, s := range swappableVouchers {
if s.TokenSymbol != string(activeSym) {
filteredSwappableVouchers = append(filteredSwappableVouchers, s)
}
}
// Store as filtered swap to list data (excluding the current active voucher) for future reference
data := store.ProcessVouchers(filteredSwappableVouchers)
logg.InfoCtxf(ctx, "ProcessVouchers", "data", data)
// Find the matching voucher data
activeSymStr := string(activeSym)
var activeData *dataserviceapi.TokenHoldings
@ -228,8 +241,12 @@ func (h *MenuHandlers) CalculateCreditAndDebt(ctx context.Context, sym string, i
kshFormattedDebt, _ := store.TruncateDecimalString(debtksh, 0)
dataMap := map[storedb.DataTyp]string{
storedb.DATA_CURRENT_CREDIT: kshFormattedCredit,
storedb.DATA_CURRENT_DEBT: kshFormattedDebt,
storedb.DATA_POOL_TO_SYMBOLS: data.Symbols,
storedb.DATA_POOL_TO_BALANCES: data.Balances,
storedb.DATA_POOL_TO_DECIMALS: data.Decimals,
storedb.DATA_POOL_TO_ADDRESSES: data.Addresses,
storedb.DATA_CURRENT_CREDIT: kshFormattedCredit,
storedb.DATA_CURRENT_DEBT: kshFormattedDebt,
}
// Write data entries