-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: adrena-perp-trading #2261
Conversation
recommend creating separate plugin! |
Won't be able to use a separate plugin; it uses the same kit from solana-agent-kit: here |
@coderabbitai review |
📝 WalkthroughWalkthroughThe pull request introduces enhancements to the Solana AgentKit plugin, expanding its capabilities with new actions and constants. The changes include adding support for perpetual trades on the Adrena protocol, introducing token-related constants, and extending the plugin's action set. The modifications prepare the infrastructure for more complex trading and token creation operations within the Solana ecosystem. Changes
Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
🧹 Nitpick comments (3)
packages/plugin-solana-agentkit/src/actions/openPerpTrade.ts (1)
181-187
: Enhance success feedback to the userProvide more details upon successful trade execution, such as a link to the transaction on a block explorer.
packages/plugin-solana-agentkit/src/types.ts (1)
3-8
: Standardize interface namingConsider using
FlashTradeContent
instead offlashTradeContent
to follow PascalCase convention for interface names.Rename the interface:
-export interface flashTradeContent extends Content { +export interface FlashTradeContent extends Content { token: string; side: "long" | "short"; collateralUsd: number; leverage: number; }packages/plugin-solana-agentkit/src/constants.ts (1)
33-35
: Consider environment-based API URL configuration.The hardcoded API URL might make it difficult to switch between environments (e.g., testnet). Also, the empty referral address needs attention.
Consider using environment variables:
export const JUP_API = process.env.JUP_API_URL || "https://quote-api.jup.ag/v6"; export const JUP_REFERRAL_ADDRESS = process.env.JUP_REFERRAL_ADDRESS || "";
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
packages/plugin-solana-agentkit/src/actions/createToken.ts
(1 hunks)packages/plugin-solana-agentkit/src/actions/openPerpTrade.ts
(1 hunks)packages/plugin-solana-agentkit/src/constants.ts
(1 hunks)packages/plugin-solana-agentkit/src/index.ts
(1 hunks)packages/plugin-solana-agentkit/src/types.ts
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- packages/plugin-solana-agentkit/src/actions/createToken.ts
🔇 Additional comments (4)
packages/plugin-solana-agentkit/src/actions/openPerpTrade.ts (1)
169-176
: Add input validation before executing tradeEnsure all inputs are valid before calling
openPerpTradeLong
to prevent runtime errors.Add checks for
content.price
,content.collateralAmount
, and other required fields.packages/plugin-solana-agentkit/src/index.ts (2)
3-3
:⚠️ Potential issueFix typo in variable name
Variable
solanaAgentkitPlguin
is misspelled.Correct the variable name:
-export const solanaAgentkitPlguin: Plugin = { +export const solanaAgentkitPlugin: Plugin = {Update all references accordingly.
Likely invalid or redundant comment.
10-10
: Ensure new action is properly integratedVerify that
openPerpTrade
is correctly imported and added to theactions
array.Confirm import statement:
-import openPerpTrade from "./actions/openPerpTrade.ts"; +import openPerpTrade from "./actions/openPerpTrade";Ensure consistency in import paths.
✅ Verification successful
Import and integration are correct, extension is stylistic
The
openPerpTrade
action is properly imported and added to theactions
array. The.ts
extension in the import path is valid, though removing it would maintain consistency with common TypeScript practices.🏁 Scripts executed
The following scripts were executed for the analysis:
Error: No shell scripts found
Script:
#!/bin/bash # Find openPerpTrade file fd openPerpTrade packages/plugin-solana-agentkit/src/actions # Check import statement and actions array usage ast-grep --pattern 'import openPerpTrade from "./actions/openPerpTrade"' ast-grep --pattern 'import openPerpTrade from "./actions/openPerpTrade.ts"' # Get the content of index.ts to see the actions array cat packages/plugin-solana-agentkit/src/index.tsLength of output: 856
packages/plugin-solana-agentkit/src/constants.ts (1)
1-15
: Verify token addresses on Solana mainnet.The token addresses look valid, and the implementation is type-safe.
Let's verify these addresses:
✅ Verification successful
All token addresses verified on Solana mainnet
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify token addresses exist on Solana mainnet # Note: Using curl to query Solana RPC endpoint for token in EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB USDSwr9ApdHk5bvJKMjzff41FfuX8bSxdKcR81vTwcA So11111111111111111111111111111111111111112 J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1 mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263; do curl -s -X POST https://api.mainnet-beta.solana.com -H "Content-Type: application/json" -d "{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"getAccountInfo\", \"params\": [\"$token\"] }" | jq '.result.value != null' doneLength of output: 5083
can you resolve the flagged issues above @pann0x |
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Resolved, await commits. |
modelClass: ModelClass.LARGE, | ||
}); | ||
|
||
//todo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason for these?
/** | ||
* Common token addresses used across the toolkit | ||
*/ | ||
export const TOKENS = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possible to get these from jup api?
@@ -0,0 +1,8 @@ | |||
import { Content } from "@elizaos/core"; | |||
|
|||
export interface flashTradeContent extends Content { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is this interface used?
please reopen when feedback implemented |
Relates to
N/A
Risks
Low
Background
What does this PR do?
Adds feature to open perpetual trading using adrena protocol through solana-agent-kit.
What kind of change is this?
features (non-breaking, only adding functionality)
expect added features including closing a position, shorting, and reducing parameters required such as contract address and price. (feel free to include missing features)
Enables sized positions on-chain through user input.
Documentation changes needed?
No changes required.
Testing
Where should a reviewer start?
go to plugin-solana-agentkit
Detailed testing steps
mention all parameters required. change are expected.