From 6abcb97f3a8964d2fc00c43fe339177e565b679c Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Wed, 18 Feb 2026 12:27:22 +0300 Subject: [PATCH] multiply the final amount by 1.015 to slightly increase the swapped amount --- handlers/application/send.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/handlers/application/send.go b/handlers/application/send.go index bbcea64..f460974 100644 --- a/handlers/application/send.go +++ b/handlers/application/send.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "math/big" "strconv" "strings" "time" @@ -757,6 +758,17 @@ func (h *MenuHandlers) TransactionSwapPreview(ctx context.Context, sym string, i return res, err } + // multiply by 1.015 (i.e. * 1015 / 1000) + amountInt, ok := new(big.Int).SetString(finalAmountStr, 10) + if !ok { + return res, fmt.Errorf("invalid amount: %s", finalAmountStr) + } + + amountInt.Mul(amountInt, big.NewInt(1015)) + amountInt.Div(amountInt, big.NewInt(1000)) + + finalAmountStr = amountInt.String() + // call the credit send API to get the reverse quote r, err := h.accountService.GetCreditSendReverseQuote(ctx, swapData.ActivePoolAddress, swapData.ActiveSwapFromAddress, swapData.ActiveSwapToAddress, finalAmountStr) if err != nil { @@ -778,15 +790,15 @@ func (h *MenuHandlers) TransactionSwapPreview(ctx context.Context, sym string, i } // Scale down the quoted output amount - quoteAmountStr := store.ScaleDownBalance(sendOutputAmount, swapData.ActiveSwapToDecimal) + // quoteAmountStr := store.ScaleDownBalance(sendOutputAmount, swapData.ActiveSwapToDecimal) // Format the qouteAmount amount to 2 decimal places - qouteAmount, _ := store.TruncateDecimalString(quoteAmountStr, 2) + // qouteAmount, _ := store.TruncateDecimalString(quoteAmountStr, 2) // store the qouteAmount in the temporary value - err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(qouteAmount)) + err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(inputStr)) if err != nil { - logg.ErrorCtxf(ctx, "failed to write temporary qouteAmount entry with", "key", storedb.DATA_TEMPORARY_VALUE, "value", qouteAmount, "error", err) + logg.ErrorCtxf(ctx, "failed to write temporary inputStr entry with", "key", storedb.DATA_TEMPORARY_VALUE, "value", inputStr, "error", err) return res, err } @@ -799,7 +811,7 @@ func (h *MenuHandlers) TransactionSwapPreview(ctx context.Context, sym string, i res.Content = l.Get( "%s will receive %s %s", - string(recipientPhoneNumber), qouteAmount, swapData.ActiveSwapToSym, + string(recipientPhoneNumber), inputStr, swapData.ActiveSwapToSym, ) return res, nil