SPL transfer and Jupiter swap fail for fractional amounts like 2.01
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- typescript
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- TypeScript
- Estrellas
- 1.3k
- Forks
- 871
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de coinbase/agentkit
-
Moonwell redeem fails on Base Sepolia and uses 18 decimals for cbBTCPosiblemente ocupada @sebxt la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
ERC20 transfer reports "Transferred" when the transaction reverts (receipt status ignored)Posiblemente ocupada @AgenticFinanceGraph la tomó hace 9 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
coinbase/agentkit#1558 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[TypeScript] `ViemWalletProvider` rejects a wallet client from a newer viem than the exactly pinned one (TS2345, `tokens` missing on `Client`)Posiblemente ocupada @PrabalParihar la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
coinbase/agentkit#1532 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
coinbase-agentkit 0.7.x fails on fresh install: imports solana.rpc.api, which solana>=0.37 removedPosiblemente ocupada @JulienKervarrec la tomó hace 28 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
x402 action provider: optional beforePayment hook to approve or block a paymentPosiblemente ocupada @snefhew la tomó hace 2 días. Abierto
Dificultad 4/5 1-2 días Aptitud para principiantes 55/100
coinbase/agentkit#1576 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de coinbase/agentkit
Issues similares
-
[BUG] rag: sentence content can cross the reported sentence boundariesPosiblemente ocupada @LJK-ikun la tomó hoy. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
bug needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
README: the Resource URI Schemas example's file://documents/* pattern only matches that literal URIAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
platformatic/mcp#361 ·
Los mantenedores suelen responder en 1 día
-
frontend
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Push: sem service worker ou sem VAPID, o interruptor de Notificações fica ligado sem avisar nadaAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
melgarafael/DeskcommCRM#3164 ·
Los mantenedores suelen responder en 1 día