Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7978d6f

Browse files
committedJan 9, 2025
get client running
1 parent 8f81106 commit 7978d6f

File tree

5 files changed

+1714
-1988
lines changed

5 files changed

+1714
-1988
lines changed
 

‎agent/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { SqliteDatabaseAdapter } from "@elizaos/adapter-sqlite";
33
import { AutoClientInterface } from "@elizaos/client-auto";
44
import { DiscordClientInterface } from "@elizaos/client-discord";
55
import { FarcasterAgentClient } from "@elizaos/client-farcaster";
6-
import { CoinbaseAgentClient } from "@elizaos/client-coinbase";
6+
import { CoinbaseClient } from "@elizaos/client-coinbase";
77
import { LensAgentClient } from "@elizaos/client-lens";
88
import { SlackClientInterface } from "@elizaos/client-slack";
99
import { TelegramClientInterface } from "@elizaos/client-telegram";
@@ -431,7 +431,7 @@ export async function initializeClients(
431431

432432
if (clientTypes.includes(Clients.COINBASE)) {
433433
// why is this one different :(
434-
const coinbaseClient = new CoinbaseAgentClient(runtime);
434+
const coinbaseClient = new CoinbaseClient(runtime);
435435
if (coinbaseClient) {
436436
coinbaseClient.start();
437437
clients.coinbase = coinbaseClient;

‎packages/client-coinbase/src/index.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ import {
1010
import { postTweet } from "@elizaos/plugin-twitter";
1111
import express from "express";
1212
import { WebhookEvent } from "./types";
13-
import { EventEmitter } from "events";
1413

15-
export class CoinbaseClient extends EventEmitter {
14+
export class CoinbaseClient implements Client {
1615
private runtime: IAgentRuntime;
1716
private server: express.Application;
1817
private port: number;
1918

2019
constructor(runtime: IAgentRuntime) {
21-
super();
2220

2321
this.runtime = runtime;
2422
this.server = express();
@@ -81,19 +79,21 @@ export class CoinbaseClient extends EventEmitter {
8179
await this.runtime.ensureRoomExists(roomId);
8280
await this.runtime.ensureParticipantInRoom(this.runtime.agentId, roomId);
8381

82+
const amount = this.runtime.getSetting('COINBASE_TRADING_AMOUNT') ?? 1;
8483
const memory: Memory = {
8584
id: stringToUuid(`coinbase-${event.timestamp}`),
8685
userId: this.runtime.agentId,
8786
agentId: this.runtime.agentId,
8887
roomId,
8988
content: {
90-
text: `Received ${event.event} signal for ${event.ticker} at price ${event.price}`,
89+
text: `Place an advanced market order to ${event.event.toLowerCase()} $${amount} worth of ${event.ticker}`,
9190
action: "EXECUTE_ADVANCED_TRADE",
9291
source: "coinbase",
9392
metadata: {
9493
ticker: event.ticker,
9594
side: event.event.toUpperCase(),
9695
price: event.price,
96+
amount: amount,
9797
timestamp: event.timestamp
9898
}
9999
},
@@ -111,12 +111,12 @@ export class CoinbaseClient extends EventEmitter {
111111
await this.runtime.processActions(memory, [memory], state, callback);
112112

113113
// Generate tweet content
114-
const tweetContent = `🚀 I just bought ${event.event.toUpperCase()} for ${event.ticker}! Current price: $${event.price}. #Coinbase #Crypto`;
114+
const tweetContent = `🚀 ${event.event.toUpperCase()} for ${event.ticker}! Amount: $${amount}. Current price: $${event.price}. `;
115115

116-
// Call postTweet
117116
try {
118-
await postTweet(tweetContent);
119-
elizaLogger.info("Tweet posted successfully:", tweetContent);
117+
elizaLogger.info("Tweet content:", tweetContent);
118+
const response = await postTweet(tweetContent);
119+
elizaLogger.info("Tweet response:", response);
120120
} catch (error) {
121121
elizaLogger.error("Failed to post tweet:", error);
122122
}

‎packages/plugin-twitter/src/actions/post.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ async function composeTweet(
6060
}
6161
}
6262

63-
async function postTweet(content: string): Promise<boolean> {
63+
export async function postTweet(content: string): Promise<boolean> {
6464
try {
6565
const scraper = new Scraper();
6666
const username = process.env.TWITTER_USERNAME;

‎packages/plugin-twitter/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ export const twitterPlugin: Plugin = {
99
providers: [],
1010
};
1111

12+
export { postTweet } from "./actions/post";
1213
export default twitterPlugin;

‎pnpm-lock.yaml

+1,702-1,977
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.