SPL transfer and Jupiter swap fail for fractional amounts like 2.01
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- typescript
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- TypeScript
- スター
- 1.3k
- フォーク
- 871
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
coinbase/agentkit のほかの issue
-
Moonwell redeem fails on Base Sepolia and uses 18 decimals for cbBTC対応中かも @sebxt が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
ERC20 transfer reports "Transferred" when the transaction reverts (receipt status ignored)対応中かも @AgenticFinanceGraph が 9 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
coinbase/agentkit#1558 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
coinbase/agentkit#1532 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
coinbase-agentkit 0.7.x fails on fresh install: imports solana.rpc.api, which solana>=0.37 removed対応中かも @JulienKervarrec が 28 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
x402 action provider: optional beforePayment hook to approve or block a payment対応中かも @snefhew が 1 日前に担当しました。 オープン
難易度 4/5 1〜2日 初心者へのやさしさ 55/100
coinbase/agentkit#1576 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
coinbase/agentkit の issue をすべて見る
似ている issue
-
check:passed streams:edit
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
area:mcp bug has repro platform:vscode regression
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
anthropics/claude-code#103970 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
sdk-typescript: unquoted COPY globs in shell form are silently dropped from the image build contextオープンbug javascript
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信