You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+87Lines changed: 87 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,7 @@ Solana Agent Kit provides a growing library of plugins that enhance your Solana
38
38
* MCP - Interface with MCP web servers
39
39
* Image Generation - Generate images with OpenAI, Grok, or Gemini with uploading to S3 compatible storage
40
40
* Nemo Agent - Generate Python projects with Nemo Agent with uploading to S3 compatible storage
41
+
* Token Math - Reliable token amount calculations for swaps, limit orders, and transfers (LLMs are bad at math!)
41
42
42
43
## 📦 Installation
43
44
@@ -835,6 +836,92 @@ config = {
835
836
}
836
837
```
837
838
839
+
### Token Math
840
+
841
+
This plugin provides reliable token amount calculations for swaps, limit orders, and transfers. **LLMs are notoriously bad at math** - they drop zeros, mess up decimal conversions, and hallucinate calculations. This tool does the math reliably so your agent doesn't lose the user money.
842
+
843
+
No config is needed - it's pure math with no external dependencies.
844
+
845
+
```python
846
+
config = {
847
+
"agents": [
848
+
{
849
+
"name": "trading_agent",
850
+
"instructions": """
851
+
ALWAYS use the token_math tool BEFORE calling privy_ultra, privy_transfer, or privy_trigger!
852
+
853
+
For swaps (privy_ultra):
854
+
1. Get token price and decimals from Birdeye
855
+
2. Call token_math action="swap" with usd_amount, token_price_usd, decimals
856
+
3. Use the returned smallest_units as the amount for privy_ultra
857
+
858
+
For transfers (privy_transfer):
859
+
1. Get token price from Birdeye
860
+
2. Call token_math action="transfer" with usd_amount, token_price_usd
861
+
3. Use the returned amount for privy_transfer
862
+
863
+
For limit orders (privy_trigger):
864
+
1. Get prices and decimals for BOTH tokens from Birdeye
865
+
2. Call token_math action="limit_order" with all params
866
+
3. Use the returned making_amount and taking_amount for privy_trigger
867
+
868
+
NEVER calculate amounts yourself - use token_math!
0 commit comments