forked from goat-sdk/goat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
5,483 additions
and
5,739 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,51 @@ | ||
# Goat ERC20 Plugin 🐐 - TypeScript | ||
|
||
ERC20 plugin for Goat. Allows you to create tools for transferring and getting the balance of ERC20 tokens. | ||
|
||
## Installation | ||
``` | ||
npm install @goat-sdk/plugin-erc20 | ||
``` | ||
|
||
## Usage | ||
|
||
```typescript | ||
import { erc20 } from "@goat-sdk/plugin-erc20"; | ||
|
||
|
||
const plugin = erc20({ | ||
tokens: [USDC, PEPE], | ||
}); | ||
``` | ||
|
||
### Adding custom tokens | ||
```typescript | ||
import { erc20 } from "@goat-sdk/plugin-erc20"; | ||
|
||
|
||
const plugin = erc20({ | ||
tokens: [ | ||
USDC, | ||
{ | ||
decimals: 18, | ||
symbol: "SHIB", | ||
name: "Shiba Inu", | ||
chains: { | ||
"1": { | ||
contractAddress: "0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE", | ||
}, | ||
}, | ||
}, | ||
], | ||
}); | ||
``` | ||
|
||
## 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. |
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,33 @@ | ||
{ | ||
"name": "@goat-sdk/plugin-erc20", | ||
"version": "0.1.7", | ||
"files": ["dist/**/*", "README.md", "package.json"], | ||
"scripts": { | ||
"build": "tsup", | ||
"clean": "rm -rf dist", | ||
"test": "vitest run --passWithNoTests" | ||
}, | ||
"sideEffects": false, | ||
"main": "./dist/index.js", | ||
"module": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
"dependencies": { | ||
"@goat-sdk/core": "workspace:*", | ||
"viem": "^2.21.49", | ||
"zod": "^3.23.8" | ||
}, | ||
"peerDependencies": { | ||
"@goat-sdk/core": "workspace:*", | ||
"viem": "^2.21.49" | ||
}, | ||
"homepage": "https://ohmygoat.dev", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/goat-sdk/goat.git" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/goat-sdk/goat/issues" | ||
}, | ||
"keywords": ["ai", "agents", "web3"] | ||
} |
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,243 @@ | ||
import { parseAbi } from "viem"; | ||
|
||
export const CFA_FORWARDER_ABI = [ | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "contract ISuperfluid", | ||
name: "host", | ||
type: "address", | ||
}, | ||
], | ||
stateMutability: "nonpayable", | ||
type: "constructor", | ||
}, | ||
{ inputs: [], name: "CFA_FWD_INVALID_FLOW_RATE", type: "error" }, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "contract ISuperToken", | ||
name: "token", | ||
type: "address", | ||
}, | ||
{ internalType: "address", name: "sender", type: "address" }, | ||
{ internalType: "address", name: "receiver", type: "address" }, | ||
{ internalType: "int96", name: "flowrate", type: "int96" }, | ||
{ internalType: "bytes", name: "userData", type: "bytes" }, | ||
], | ||
name: "createFlow", | ||
outputs: [{ internalType: "bool", name: "", type: "bool" }], | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "contract ISuperToken", | ||
name: "token", | ||
type: "address", | ||
}, | ||
{ internalType: "address", name: "sender", type: "address" }, | ||
{ internalType: "address", name: "receiver", type: "address" }, | ||
{ internalType: "bytes", name: "userData", type: "bytes" }, | ||
], | ||
name: "deleteFlow", | ||
outputs: [{ internalType: "bool", name: "", type: "bool" }], | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "contract ISuperToken", | ||
name: "token", | ||
type: "address", | ||
}, | ||
{ internalType: "address", name: "account", type: "address" }, | ||
], | ||
name: "getAccountFlowInfo", | ||
outputs: [ | ||
{ internalType: "uint256", name: "lastUpdated", type: "uint256" }, | ||
{ internalType: "int96", name: "flowrate", type: "int96" }, | ||
{ internalType: "uint256", name: "deposit", type: "uint256" }, | ||
{ internalType: "uint256", name: "owedDeposit", type: "uint256" }, | ||
], | ||
stateMutability: "view", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "contract ISuperToken", | ||
name: "token", | ||
type: "address", | ||
}, | ||
{ internalType: "address", name: "account", type: "address" }, | ||
], | ||
name: "getAccountFlowrate", | ||
outputs: [{ internalType: "int96", name: "flowrate", type: "int96" }], | ||
stateMutability: "view", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "contract ISuperToken", | ||
name: "token", | ||
type: "address", | ||
}, | ||
{ internalType: "int96", name: "flowrate", type: "int96" }, | ||
], | ||
name: "getBufferAmountByFlowrate", | ||
outputs: [ | ||
{ internalType: "uint256", name: "bufferAmount", type: "uint256" }, | ||
], | ||
stateMutability: "view", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "contract ISuperToken", | ||
name: "token", | ||
type: "address", | ||
}, | ||
{ internalType: "address", name: "sender", type: "address" }, | ||
{ internalType: "address", name: "receiver", type: "address" }, | ||
], | ||
name: "getFlowInfo", | ||
outputs: [ | ||
{ internalType: "uint256", name: "lastUpdated", type: "uint256" }, | ||
{ internalType: "int96", name: "flowrate", type: "int96" }, | ||
{ internalType: "uint256", name: "deposit", type: "uint256" }, | ||
{ internalType: "uint256", name: "owedDeposit", type: "uint256" }, | ||
], | ||
stateMutability: "view", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "contract ISuperToken", | ||
name: "token", | ||
type: "address", | ||
}, | ||
{ internalType: "address", name: "sender", type: "address" }, | ||
{ internalType: "address", name: "flowOperator", type: "address" }, | ||
], | ||
name: "getFlowOperatorPermissions", | ||
outputs: [ | ||
{ internalType: "uint8", name: "permissions", type: "uint8" }, | ||
{ internalType: "int96", name: "flowrateAllowance", type: "int96" }, | ||
], | ||
stateMutability: "view", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "contract ISuperToken", | ||
name: "token", | ||
type: "address", | ||
}, | ||
{ internalType: "address", name: "sender", type: "address" }, | ||
{ internalType: "address", name: "receiver", type: "address" }, | ||
], | ||
name: "getFlowrate", | ||
outputs: [{ internalType: "int96", name: "flowrate", type: "int96" }], | ||
stateMutability: "view", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "contract ISuperToken", | ||
name: "token", | ||
type: "address", | ||
}, | ||
{ internalType: "address", name: "flowOperator", type: "address" }, | ||
], | ||
name: "grantPermissions", | ||
outputs: [{ internalType: "bool", name: "", type: "bool" }], | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "contract ISuperToken", | ||
name: "token", | ||
type: "address", | ||
}, | ||
{ internalType: "address", name: "flowOperator", type: "address" }, | ||
], | ||
name: "revokePermissions", | ||
outputs: [{ internalType: "bool", name: "", type: "bool" }], | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "contract ISuperToken", | ||
name: "token", | ||
type: "address", | ||
}, | ||
{ internalType: "address", name: "receiver", type: "address" }, | ||
{ internalType: "int96", name: "flowrate", type: "int96" }, | ||
], | ||
name: "setFlowrate", | ||
outputs: [{ internalType: "bool", name: "", type: "bool" }], | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "contract ISuperToken", | ||
name: "token", | ||
type: "address", | ||
}, | ||
{ internalType: "address", name: "sender", type: "address" }, | ||
{ internalType: "address", name: "receiver", type: "address" }, | ||
{ internalType: "int96", name: "flowrate", type: "int96" }, | ||
], | ||
name: "setFlowrateFrom", | ||
outputs: [{ internalType: "bool", name: "", type: "bool" }], | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "contract ISuperToken", | ||
name: "token", | ||
type: "address", | ||
}, | ||
{ internalType: "address", name: "sender", type: "address" }, | ||
{ internalType: "address", name: "receiver", type: "address" }, | ||
{ internalType: "int96", name: "flowrate", type: "int96" }, | ||
{ internalType: "bytes", name: "userData", type: "bytes" }, | ||
], | ||
name: "updateFlow", | ||
outputs: [{ internalType: "bool", name: "", type: "bool" }], | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "contract ISuperToken", | ||
name: "token", | ||
type: "address", | ||
}, | ||
{ internalType: "address", name: "flowOperator", type: "address" }, | ||
{ internalType: "uint8", name: "permissions", type: "uint8" }, | ||
{ internalType: "int96", name: "flowrateAllowance", type: "int96" }, | ||
], | ||
name: "updateFlowOperatorPermissions", | ||
outputs: [{ internalType: "bool", name: "", type: "bool" }], | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
}, | ||
]; |
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,28 @@ | ||
import type { Chain, EVMWalletClient, Plugin } from "@goat-sdk/core"; | ||
import { PEPE, type Token, USDC, getTokensForNetwork } from "./token"; | ||
import { getTools } from "./tools"; | ||
|
||
export type { Token }; | ||
export { USDC, PEPE }; | ||
|
||
export type ERC20Options = { | ||
tokens: Token[]; | ||
}; | ||
|
||
export function erc20({ tokens }: ERC20Options): Plugin<EVMWalletClient> { | ||
return { | ||
name: "ERC20", | ||
supportsChain: (chain: Chain) => chain.type === "evm", | ||
supportsSmartWallets: () => true, | ||
getTools: async (chain: Chain) => { | ||
const network = chain; | ||
|
||
if (!network.id) { | ||
throw new Error("Network ID is required"); | ||
} | ||
|
||
const tokenList = getTokensForNetwork(network.id, tokens); | ||
return getTools(tokenList); | ||
}, | ||
}; | ||
} |
Oops, something went wrong.