Skip to content

Commit

Permalink
start superfluid plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
youssefea committed Dec 8, 2024
1 parent f32d00a commit 5edf5b2
Show file tree
Hide file tree
Showing 14 changed files with 5,483 additions and 5,739 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"vitest": "2.1.5"
},
"engines": {
"node": ">=20.12.2 <21",
"node": ">=20.12.2",
"npm": "please-use-pnpm",
"pnpm": ">=9",
"pnpm": ">=8",
"yarn": "please-use-pnpm"
},
"homepage": "https://github.com/crossmint/goat",
Expand Down
51 changes: 51 additions & 0 deletions typescript/packages/plugins/superfluid/README.md
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.
33 changes: 33 additions & 0 deletions typescript/packages/plugins/superfluid/package.json
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"]
}
243 changes: 243 additions & 0 deletions typescript/packages/plugins/superfluid/src/abi.ts
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",
},
];
28 changes: 28 additions & 0 deletions typescript/packages/plugins/superfluid/src/index.ts
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);
},
};
}
Loading

0 comments on commit 5edf5b2

Please sign in to comment.