Necta Agents is a multi-agent DeFi system that autonomously monitors market conditions and wallet status and executes transactions to optimize returns.
This system consists of three main AI agents working together:
- Sentinel Agent: Monitors market conditions, wallet status, and protocol states to generate market intelligence reports;
- Curator Agent: Analyzes observer reports and determines optimal trading actions;
- Executor Agent: Safely executes the approved trading tasks.
The goal of the Sentinel Agent is to generate reports about the current state of the market, the status of the wallet and the past operations. This report will be sent to the Curator Agent that will either approve it and generate tasks or reject it and ask for a new report.
The goal of the Curator Agent is to analyze the report generated by the Sentinel Agent and generate tasks based on the report. It can also reject the report and ask for a new one. At the end of the whole flow it will generate a final report that will be used to store the results of the executed tasks.
The goal of the Executor Agent is to execute the tasks generated by the Curator Agent. It will generate the transactions by passing the tasks to the Brian APIs and then execute them.
Necta Agents is a complex system, and requires a little bit of setup to be able to run it. Let's see all the different steps.
You need to create an account on Supabase and create a new project. Inside the project you need to create the documents table (see Memory section for more information) and the following tables:
tasks: this table is used to store the tasks that need to be executed;
create table
public.tasks (
id uuid not null default gen_random_uuid(),
created_at timestamp with time zone not null default now(),
task text not null,
steps json not null,
from_token jsonb null,
to_token jsonb null,
from_amount text null,
to_amount text null,
constraint tasks_pkey primary key (id)
) tablespace pg_default;thoughts: this table is used to store all the different agents' thoughts and messages.
create table
public.thoughts (
id bigint generated by default as identity not null,
created_at timestamp with time zone not null default now(),
agent text null,
text text null,
tool_calls json null,
tool_results json null,
constraint thoughts_pkey primary key (id)
) tablespace pg_default;You need to create a .env file in the root of the project with the following variables:
OPENAI_API_KEY=""
PORTALS_API_KEY=""
BRIAN_API_URL="https://api.brianknows.org"
BRIAN_API_KEY="brian_app_rfNZfRT3nUyQdcpyz"
SUPABASE_URL=""
SUPABASE_KEY=""
PRIVATE_KEY=""
PORT="8000"
ZERION_API_KEY=""
Run the system using bun:
bun src/index.tsYou will see the logs of the system in the console.
You can change the agents' behaviors by editing the src/system-prompts folder. Each agent has its own file.
You can update the system prompts so that the agents behave differently: an example could be changing the system to be more degen-like, or even more conservative.
Changing the behavior may include updating the existing tools or create new ones: you can do so in the toolkit.ts file of each agent, most likely you need to intervene only on the observer agent toolkit to retrieve different information, like trending tokens, etc.
Contributions are welcome! Please feel free to submit a Pull Request.