Skip to content

Commit

Permalink
add tokenInfo, and shouldTrade
Browse files Browse the repository at this point in the history
Signed-off-by: MarcoMandar <[email protected]>
  • Loading branch information
MarcoMandar committed Nov 10, 2024
1 parent 91ba22b commit 574da20
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions packages/client-auto/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,24 @@ import { TrustScoreManager } from "@ai16z/plugin-solana/src/providers/trustScore
import { TokenProvider } from "@ai16z/plugin-solana/src/providers/token.ts";
import { WalletProvider } from "@ai16z/plugin-solana/src/providers/wallet.ts";
import { TrustScoreDatabase } from "@ai16z/plugin-solana/src/adapters/trustScoreDatabase.ts";
import { Connection, PublicKey } from "@solana/web3.js";

export class AutoClient {
interval: NodeJS.Timeout;
runtime: IAgentRuntime;
trustScoreProvider: TrustScoreManager;
walletProvider: WalletProvider;

constructor(runtime: IAgentRuntime) {
this.runtime = runtime;

const trustScoreDb = new TrustScoreDatabase(runtime.databaseAdapter.db);
this.trustScoreProvider = new TrustScoreManager(null, trustScoreDb);
this.walletProvider = new WalletProvider(
new Connection(runtime.getSetting("RPC_URL")),
new PublicKey(runtime.getSetting("WALLET_PUBLIC_KEY"))
);

// start a loop that runs every x seconds
this.interval = setInterval(
async () => {
Expand Down Expand Up @@ -41,6 +48,18 @@ export class AutoClient {
);

// get information for all tokens which were recommended
const tokenInfos = highTrustRecommendations.map(
async (highTrustRecommendation) => {
const tokenProvider = new TokenProvider(
highTrustRecommendation.tokenAddress,
this.walletProvider
);
const tokenInfo = await tokenProvider.getProcessedTokenData();
const shouldTrade = await tokenProvider.shouldTradeToken();
return { tokenInfo, shouldTrade };
}
);

// get any additional information we might need
// make sure we're looking at the right tokens and data

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-solana/src/evaluators/trust.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ async function handler(runtime: IAgentRuntime, message: Memory) {
}

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

if (!shouldTrade) {
console.warn(
Expand Down

0 comments on commit 574da20

Please sign in to comment.