Skip to content

Commit 7d2398a

Browse files
authored
feat: add suilend + Navi and improve code (#32)
1 parent 1d8fe84 commit 7d2398a

File tree

18 files changed

+1940
-1308
lines changed

18 files changed

+1940
-1308
lines changed

packages/sui-agent/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"dotenv": "^16.4.7",
3030
"mongoose": "^8.10.0",
3131
"navi-sdk": "^1.4.24",
32-
"typescript": "^5.7.3"
32+
"typescript": "^5.7.3",
33+
"@suilend/sdk": "^1.1.36"
3334
},
3435
"devDependencies": {
3536
"@types/bn.js": "^5.1.6",

packages/sui-agent/src/agents/ToolRegistry.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import Tools from '../utils/tools';
22
import AfterMath from '../protocols/aftermath/tools';
33
import Navi from '../protocols/navi/tools';
44
import Cetus from '../protocols/cetus/tools';
5-
import Transaction from '../transactions/tools';
5+
import Suilend from '../protocols/suilend/tools';
6+
import TransactionTools from '../transactions/tools';
67
/*
78
format for tool registry is:
89
tool name, tool description, tool arguments, process(function)
@@ -16,5 +17,7 @@ export function registerAllTools(tools: Tools) {
1617
// Cetus tools
1718
Cetus.registerTools(tools);
1819
// Transaction Tools
19-
Transaction.registerTools(tools);
20+
TransactionTools.registerTools(tools);
21+
// Suilend tools
22+
Suilend.registerTools(tools);
2023
}

packages/sui-agent/src/prompts/final_answer_agent.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
* errors: any[] - Array of encountered errors, if any
1414
* }
1515
*
16+
* For transaction responses, format the response string as:
17+
* - Success: "Transaction successful! ✅\nView on SuiVision: https://suivision.xyz/txblock/{digest}\n\nDetails:\n- Amount: {amount} SUI\n- From: {sender}\n- To: {recipient}\n- Network: {network}"
18+
* - Failure: "Transaction failed ❌\n{error_message}\n\nPlease check:\n- You have enough SUI for transfer and gas\n- The recipient address is correct\n- Try again or use a smaller amount"
19+
*
1620
* @example
1721
* The template enforces strict response formatting to ensure consistent
1822
* output structure across different tool executions.
@@ -24,12 +28,18 @@ Write down the response in this format
2428
2529
[{
2630
"reasoning": string, // explain your reasoning in clear terms
27-
"response": string | JSON // clear terms detailed until explicitly stated otherwise. IF RESPONSE IS JSON, RETURN IT AS A JSON OBJECT
31+
"response": string | JSON // For transactions, use the special transaction format described above. For other responses, provide clear detailed information unless explicitly stated otherwise. IF RESPONSE IS JSON, RETURN IT AS A JSON OBJECT
2832
"status": string ("success"| "failure") ,// success if no errors
2933
"query": string ,// initial user query;
3034
"errors": any[], //if any
3135
}]
3236
37+
If the response contains a transaction (check for digest or transaction details):
38+
1. Always include the SuiVision link (https://suivision.xyz/txblock/{digest} or https://testnet.suivision.xyz/txblock/{digest} for testnet)
39+
2. Format amounts in human-readable form (e.g., "1 SUI" instead of "1000000000")
40+
3. Use emojis ✅ for success and ❌ for failure
41+
4. Include all transaction details in a clear, readable format
42+
3343
DO NOT UNDER ANY CIRCUMSTANCES STRAY FROM THE RESPONSE FORMAT
3444
RESPOND WITH ONLY THE RESPONSE FORMAT
3545
`;

0 commit comments

Comments
 (0)