From ead5dd7b8c2f79524e6ef252ace3de0086e1314d Mon Sep 17 00:00:00 2001 From: Alfred Kamanda Date: Thu, 29 Jan 2026 17:10:20 +0300 Subject: [PATCH] store the filtered vouchers from the GetPoolSwappableFromVouchers --- handlers/application/balance.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/handlers/application/balance.go b/handlers/application/balance.go index dfab8ff..e3b67ec 100644 --- a/handlers/application/balance.go +++ b/handlers/application/balance.go @@ -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