The Solana Plugin V2 leverages the latest features of @solana/web3.js
v2 to provide a modern, efficient, and composable solution for Solana integrations within the Eliza AI agent framework.
- @solana/web3.js v2 introduces:
- Tree-shakability
- Composable internals
- Zero-dependency design
- Functional programming approach
- This plugin can be used by the agent alongside existing plugins that use
@solana/web3.js
v1.
The Utils
class provides shared functionality across the plugin, offering flexibility and ease of integration.
- Accepts the RPC instance, transaction instructions, and a wallet.
- Utilizes Solana's Compute Budget Program for optimized CU usage and priority fees.
- Implements client-side retry logic to enhance transaction landing success.
- More details on optimizing transactions can be found here.
- For Trusted Execution Environment (TEE) functionality, this plugin transitions from
Keypair
(used in v1) toCryptoKeyPair
from the Web Crypto API. This change aligns with@solana/web3.js
v2's zero-dependency, modern JavaScript architecture. - A modified implementation for TEE integration is included in
src/utils/
, following the same patterns used inplugin-tee
.
- Reposition Liquidity:
- Automatically repositions Orca liquidity positions if the center price of the position deviates from the current pool price by more than a user-specified threshold (
repositionThresholdBps
). - Maintains the original width of the position during repositioning.
- Repositions at a user defined time interval.
- Uses a slippage tolerance set by the user.
- Automatically repositions Orca liquidity positions if the center price of the position deviates from the current pool price by more than a user-specified threshold (
- In the root of the repositorty, copy
.env.example
to.env
- Fill in the following parameters:
SOLANA_PRIVATE_KEY
SOLANA_PUBLIC_KEY
SOLANA_RPC_URL
OPENAI_API_KEY
Most often, free-tier RPC URLs are not sufficient for this plugin.
- Eliza needs to fetch all your token-accounts in order to find the position NFTs that represent Orca positions. Such calls are done through the
getProgramAccounts
method of the RPC client, which can be expensive. - To ensure transaction landing, the plugin makes use of a client-side retry logic (read more here), which also puts a heavier load on the RPC.
- The amount of positions you own and the update interval you set can also contribute to RPC limits.
In agent/src/index.ts
, search for the function createAgent
, and add solana_plugin_v2
to the AgentRuntime
like so:
export async function createAgent(
character: Character,
db: IDatabaseAdapter,
cache: ICacheManager,
token: string
): Promise<AgentRuntime> {
// Rest of the code ...
return new AgentRuntime({
// Other parameters
plugins: [
// Other plutins
getSecret(character, "SOLANA_PUBLIC_KEY") ||
(getSecret(character, "WALLET_PUBLIC_KEY") &&
!getSecret(character, "WALLET_PUBLIC_KEY")?.startsWith("0x"))
? solanaPluginV2
: null,
// Rest of the code
Copy packages/plugin-solana-v2/src/character/orca/lpmanager.character.json
to characters/lpmanager.character.json
.
Follow the general installation and build steps from the README in the root of the repo
Start the the agent with the following command:
pnpm start --characters="characters/lpmanager.character.json"
Start the client (chat terminal) with:
pnpm start:client
Ask the agent what it can do for you. Provide the appropriate parameters and let the agent reposition your positions automatically.
In packages/plugin-solana-v2/src/utils/sendTransaction.ts
, you can set the priority fees. They are by default set to use the dynamic fees, but you can adjust this as you like.
- Opening and Closing Positions:
- Expose opening and closing positions as separate actions.
- Allow agents to leverage data streams and other plugins for decision-making and yield optimization.
- Token Creation and Liquidity Setup:
- Create tokens with metadata using the Token 2022 Program.
- Launch tokens on Orca with single-sided liquidity.
- Configure start and maximum prices for initial liquidity.
Contributions are welcome! If you wish to extend plugin-solana-v2
with your tools, ensure compatibility with @solana/web3.js
v2.