Skip to content

Commit 574da20

Browse files
committed
add tokenInfo, and shouldTrade
Signed-off-by: MarcoMandar <malicemandar@gmail.com>
1 parent 91ba22b commit 574da20

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

packages/client-auto/src/index.ts

+19
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,24 @@ import { TrustScoreManager } from "@ai16z/plugin-solana/src/providers/trustScore
33
import { TokenProvider } from "@ai16z/plugin-solana/src/providers/token.ts";
44
import { WalletProvider } from "@ai16z/plugin-solana/src/providers/wallet.ts";
55
import { TrustScoreDatabase } from "@ai16z/plugin-solana/src/adapters/trustScoreDatabase.ts";
6+
import { Connection, PublicKey } from "@solana/web3.js";
67

78
export class AutoClient {
89
interval: NodeJS.Timeout;
910
runtime: IAgentRuntime;
1011
trustScoreProvider: TrustScoreManager;
12+
walletProvider: WalletProvider;
1113

1214
constructor(runtime: IAgentRuntime) {
1315
this.runtime = runtime;
1416

1517
const trustScoreDb = new TrustScoreDatabase(runtime.databaseAdapter.db);
1618
this.trustScoreProvider = new TrustScoreManager(null, trustScoreDb);
19+
this.walletProvider = new WalletProvider(
20+
new Connection(runtime.getSetting("RPC_URL")),
21+
new PublicKey(runtime.getSetting("WALLET_PUBLIC_KEY"))
22+
);
23+
1724
// start a loop that runs every x seconds
1825
this.interval = setInterval(
1926
async () => {
@@ -41,6 +48,18 @@ export class AutoClient {
4148
);
4249

4350
// get information for all tokens which were recommended
51+
const tokenInfos = highTrustRecommendations.map(
52+
async (highTrustRecommendation) => {
53+
const tokenProvider = new TokenProvider(
54+
highTrustRecommendation.tokenAddress,
55+
this.walletProvider
56+
);
57+
const tokenInfo = await tokenProvider.getProcessedTokenData();
58+
const shouldTrade = await tokenProvider.shouldTradeToken();
59+
return { tokenInfo, shouldTrade };
60+
}
61+
);
62+
4463
// get any additional information we might need
4564
// make sure we're looking at the right tokens and data
4665

packages/plugin-solana/src/evaluators/trust.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ async function handler(runtime: IAgentRuntime, message: Memory) {
233233
}
234234

235235
// TODO: is this is a buy, sell, dont buy, or dont sell?
236-
const shouldTrade = await this.tokenProvider.shouldTrade();
236+
const shouldTrade = await this.tokenProvider.shouldTradeToken();
237237

238238
if (!shouldTrade) {
239239
console.warn(

0 commit comments

Comments
 (0)