Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

SPL transfer and Jupiter swap fail for fractional amounts like 2.01

Aperta
#1,574 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@sebxt ci sta già lavorando.

Dal 18/10/2026.

  • #1575 di @sebxt — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
typescript
Ambito
api, backend

Direzione di ricerca

Start with typescript/agentkit/src/action-providers/spl/splActionProvider.ts and typescript/agentkit/src/action-providers/jupiter/jupiterActionProvider.ts, where both actions scale the amount by the mint decimals. Check the tests around SPL transfers and Jupiter quote requests, then verify that 2.01 USDC becomes the integer base unit amount 2010000 for both actions. An open linked pull request already addresses this issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What happens

SplActionProvider.transfer converts the whole unit amount to base units with plain floating point math and then calls BigInt on the result:

const adjustedAmount = args.amount * Math.pow(10, mintInfo.decimals);
...
if (sourceAccount.amount < BigInt(adjustedAmount)) {

For many ordinary amounts the product is not an integer. With a 6 decimal mint (USDC), 2.01 * 10 ** 6 is 2009999.9999999998, so BigInt throws and the action returns:

Error transferring SPL tokens: RangeError: The number 2009999.9999999998 cannot be converted to a BigInt because it is not an integer

Other examples with 6 decimals: 2.03, 2.05, 4.02. With 9 decimals: 1.07, 2.01.

JupiterActionProvider.swap uses the same conversion (args.amount * 10 ** mintInfo.decimals) and passes the fractional value straight to quoteGet as amount, so the quote request carries amount=2009999.9999999998 instead of the integer base unit amount the Jupiter API expects.

What should happen

Both actions should convert the amount to an integer number of base units (2.01 USDC is 2010000) and proceed.

Minimal repro

const provider = new SplActionProvider();
// mint with 6 decimals, sender holds enough balance
await provider.transfer(wallet, { recipient, mintAddress, amount: 2.01 });
// => "Error transferring SPL tokens: RangeError: The number 2009999.9999999998 cannot be converted to a BigInt because it is not an integer"

Or directly: BigInt(2.01 * Math.pow(10, 6)) throws.

Root cause

typescript/agentkit/src/action-providers/spl/splActionProvider.ts and typescript/agentkit/src/action-providers/jupiter/jupiterActionProvider.ts scale a JS number by 10 ** decimals without rounding. Binary floating point cannot represent most decimal fractions exactly, so the product is often a hair above or below the intended integer.

Lingua principale
TypeScript
Stelle
1.3k
Fork
871
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di coinbase/agentkit

Tutte le issue di coinbase/agentkit

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.