Compare commits

..

3 Commits

Author SHA1 Message Date
7bf71cbfff Merge pull request 'allow-stables-direct-to-mpesa' (#118) from allow-stables-direct-to-mpesa into master
Reviewed-on: #118
2026-02-26 18:17:42 +01:00
295ca6e53e
use the token transfer API for pool deposit
Some checks failed
release / docker (push) Has been cancelled
2026-02-26 14:24:04 +03:00
de32deab80
set the flag_low_swap_amount for amounts below the min withdrawal
Some checks failed
release / docker (push) Has been cancelled
2026-02-25 15:51:48 +03:00
2 changed files with 13 additions and 6 deletions

View File

@ -100,8 +100,8 @@ func (h *MenuHandlers) GetMpesaMaxLimit(ctx context.Context, sym string, input [
} }
// Fetch min withdrawal amount from config/env // Fetch min withdrawal amount from config/env
minksh := fmt.Sprintf("%f", config.MinMpesaWithdrawAmount()) minWithdraw := config.MinMpesaWithdrawAmount() // float64 (20)
minKshFormatted, _ := store.TruncateDecimalString(minksh, 0) minKshFormatted, _ := store.TruncateDecimalString(fmt.Sprintf("%f", minWithdraw), 0)
// If SAT is the same as RAT (default USDm), // If SAT is the same as RAT (default USDm),
// or if the voucher is a stable coin // or if the voucher is a stable coin
@ -115,9 +115,16 @@ func (h *MenuHandlers) GetMpesaMaxLimit(ctx context.Context, sym string, input [
} }
activeFloat, _ := strconv.ParseFloat(string(metadata.Balance), 64) activeFloat, _ := strconv.ParseFloat(string(metadata.Balance), 64)
ksh := fmt.Sprintf("%f", activeFloat*rates.Buy) kshValue := activeFloat * rates.Buy
maxKshFormatted, _ := store.TruncateDecimalString(ksh, 0) maxKshFormatted, _ := store.TruncateDecimalString(fmt.Sprintf("%f", kshValue), 0)
// Ensure that the max is greater than the min
if kshValue < minWithdraw {
res.FlagSet = append(res.FlagSet, flag_low_swap_amount)
res.Content = l.Get("%s Ksh", maxKshFormatted)
return res, nil
}
res.Content = l.Get( res.Content = l.Get(
"Enter the amount of Mpesa to withdraw: (Min: Ksh %s, Max %s Ksh)\n", "Enter the amount of Mpesa to withdraw: (Min: Ksh %s, Max %s Ksh)\n",

View File

@ -206,8 +206,8 @@ func (h *MenuHandlers) InitiatePoolDeposit(ctx context.Context, sym string, inpu
return res, err return res, err
} }
// Call pool deposit API // Call token transfer API and send the token to the pool address
r, err := h.accountService.PoolDeposit(ctx, finalAmountStr, string(publicKey), string(activePoolAddress), poolDepositVoucher.TokenAddress) r, err := h.accountService.TokenTransfer(ctx, finalAmountStr, string(publicKey), string(activePoolAddress), poolDepositVoucher.TokenAddress)
if err != nil { if err != nil {
flag_api_call_error, _ := h.flagManager.GetFlag("flag_api_call_error") flag_api_call_error, _ := h.flagManager.GetFlag("flag_api_call_error")
res.FlagSet = append(res.FlagSet, flag_api_call_error) res.FlagSet = append(res.FlagSet, flag_api_call_error)