-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix Jupiter plugin - Execute tx - Add convert to base units tool - Add ability to set custom SLP tokens * Add changesets
- Loading branch information
1 parent
786e966
commit a66ceec
Showing
18 changed files
with
249 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
"@goat-sdk/adapter-vercel-ai": patch | ||
"@goat-sdk/plugin-spl-token": patch | ||
"goat-examples-vercel-ai-solana": patch | ||
"@goat-sdk/plugin-jupiter": patch | ||
"@goat-sdk/wallet-solana": patch | ||
"@goat-sdk/core": patch | ||
--- | ||
|
||
Fix jupiter swap tokens tx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
OPENAI_API_KEY= | ||
WALLET_MNEMONIC= | ||
SOLANA_RPC_URL= | ||
SOLANA_PRIVATE_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Goat SPL Token Plugin 🐐 - TypeScript | ||
|
||
SPL Token plugin for Goat. Allows you to create tools for transferring and getting the balance of SPL tokens. | ||
|
||
## Installation | ||
``` | ||
npm install @goat-sdk/plugin-spl-token | ||
``` | ||
|
||
## Usage | ||
|
||
```typescript | ||
import { splToken, USDC, GOAT } from "@goat-sdk/plugin-spl-token"; | ||
|
||
const plugin = splToken({ | ||
connection, | ||
network: "mainnet", | ||
tokens: [USDC, GOAT], | ||
}); | ||
``` | ||
|
||
### Adding custom tokens | ||
```typescript | ||
import { splToken } from "@goat-sdk/plugin-spl-token"; | ||
|
||
|
||
const plugin = splToken({ | ||
tokens: [ | ||
USDC, | ||
{ | ||
decimals: 9, | ||
symbol: "POPCAT", | ||
name: "Popcat", | ||
mintAddresses: { | ||
"mainnet": "7GCihgDB8fe6KNjn2MYtkzZcRjQy3t9GHdC8uHYmW2hr", | ||
}, | ||
}, | ||
], | ||
}); | ||
``` | ||
|
||
## Goat | ||
|
||
<div align="center"> | ||
Go out and eat some grass. | ||
|
||
[Docs](https://ohmygoat.dev) | [Examples](https://github.com/goat-sdk/goat/tree/main/typescript/examples) | [Discord](https://discord.gg/goat-sdk)</div> | ||
|
||
## Goat 🐐 | ||
Goat 🐐 (Great Onchain Agent Toolkit) is an open-source library enabling AI agents to interact with blockchain protocols and smart contracts via their own wallets. |
4 changes: 4 additions & 0 deletions
4
typescript/packages/plugins/spl-token/src/methods/convert-to-base-unit.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export async function convertToBaseUnit(amount: number, decimals: number) { | ||
const baseUnit = amount * 10 ** decimals; | ||
return baseUnit; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
import type { Plugin, SolanaWalletClient } from "@goat-sdk/core"; | ||
import type { Connection } from "@solana/web3.js"; | ||
import type { SolanaNetwork } from "./tokens"; | ||
import type { SolanaNetwork, Token } from "./tokens"; | ||
import { SPL_TOKENS } from "./tokens"; | ||
import { getTools } from "./utils/getTools"; | ||
|
||
export function splToken({ | ||
connection, | ||
network, | ||
}: { connection: Connection; network: SolanaNetwork }): Plugin<SolanaWalletClient> { | ||
tokens = SPL_TOKENS, | ||
}: { connection: Connection; network: SolanaNetwork; tokens?: Token[] }): Plugin<SolanaWalletClient> { | ||
return { | ||
name: "splToken", | ||
supportsSmartWallets: () => false, | ||
supportsChain: (chain) => chain.type === "solana", | ||
getTools: async (walletClient: SolanaWalletClient) => getTools(walletClient, connection, network), | ||
getTools: async (walletClient: SolanaWalletClient) => getTools(walletClient, connection, network, tokens), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
typescript/packages/plugins/spl-token/src/utils/getTokenInfoBySymbol.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { SolanaNetwork, Token } from "../tokens"; | ||
|
||
export function getTokenInfoBySymbol(symbol: string, tokens: Token[], network: SolanaNetwork) { | ||
const token = tokens.find((token) => [token.symbol, token.symbol.toLowerCase()].includes(symbol)); | ||
return { | ||
symbol: token?.symbol, | ||
mintAddress: token?.mintAddresses[network], | ||
decimals: token?.decimals, | ||
name: token?.name, | ||
}; | ||
} |
Oops, something went wrong.