Skip to content

Commit d2540fa

Browse files
committed
update transaction tools
1 parent 2398ae8 commit d2540fa

File tree

5 files changed

+265
-381
lines changed

5 files changed

+265
-381
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ 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 TransactionTools from '../transactions/tools';
66
import Suilend from '../protocols/suilend/tools';
77
/*
88
format for tool registry is:
@@ -17,7 +17,7 @@ export function registerAllTools(tools: Tools) {
1717
// Cetus tools
1818
Cetus.registerTools(tools);
1919
// Transaction Tools
20-
Transaction.registerTools(tools);
20+
TransactionTools.registerTools(tools);
2121
// Suilend tools
2222
Suilend.registerTools(tools);
2323
}
Lines changed: 106 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,135 @@
1-
## Navi Protocol Integration
1+
# Navi Protocol Integration
22

3-
The Sui Agent includes integration with the Navi Protocol, providing access to Navi's DeFi functionality and perpetual trading features.
3+
This module provides integration with the Navi perpetual trading protocol on Sui Network.
44

5-
### Features
5+
## Features
66

7-
#### Perpetual Trading
7+
- Order Management
8+
- Place orders (market/limit)
9+
- Cancel orders
10+
- Get user orders
11+
- Position Management
12+
- Open positions
13+
- Close positions
14+
- Get user positions
15+
- Adjust leverage
16+
- Adjust margin
17+
- Market Data
18+
- Get orderbook
19+
- Get market data
20+
- Get funding rates
21+
- Account Management
22+
- Get account info
23+
- Get account balance
24+
- Get account positions
825

9-
- Open and close positions
10-
- Manage leverage and margin
11-
- Monitor position metrics
12-
- Track funding rates
26+
## Tools
1327

14-
#### Market Data
28+
### Order Management
1529

16-
- Get real-time prices
17-
- View market statistics
18-
- Monitor trading volume
19-
- Track historical data
30+
#### `place_navi_order`
2031

21-
#### Account Management
32+
Place a new order on Navi.
2233

23-
- View account positions
24-
- Monitor margin levels
25-
- Track PnL
26-
- Manage collateral
34+
Parameters:
2735

28-
### Example Usage
36+
- `symbol` (string, required): Trading pair symbol (e.g., "BTC-PERP")
37+
- `side` (string, required): Order side ("BUY" or "SELL")
38+
- `type` (string, required): Order type ("MARKET" or "LIMIT")
39+
- `quantity` (number, required): Order quantity
40+
- `price` (number, optional): Order price (required for LIMIT orders)
41+
- `leverage` (number, optional): Position leverage
2942

30-
```typescript
31-
// Initialize the agent
32-
const agent = new Agents(YOUR_BEARER_TOKEN);
33-
34-
// Get market information
35-
const marketInfo = await agent.SuperVisorAgent(
36-
'Get Navi market information for BTC-PERP',
37-
);
38-
39-
// Open a position
40-
const position = await agent.SuperVisorAgent(
41-
'Open a long position on Navi BTC-PERP with 5x leverage and 100 USDC as margin',
42-
);
43-
44-
// Check account positions
45-
const positions = await agent.SuperVisorAgent(
46-
'Get my Navi positions for address 0x123...abc',
47-
);
48-
49-
// Monitor funding rate
50-
const funding = await agent.SuperVisorAgent(
51-
'Get current funding rate for Navi BTC-PERP market',
52-
);
53-
```
43+
#### `cancel_navi_order`
44+
45+
Cancel an existing order on Navi.
46+
47+
Parameters:
48+
49+
- `symbol` (string, required): Trading pair symbol
50+
- `order_id` (string, required): Order ID to cancel
51+
52+
### Position Management
53+
54+
#### `adjust_navi_position`
55+
56+
Adjust position leverage on Navi.
57+
58+
Parameters:
59+
60+
- `symbol` (string, required): Trading pair symbol
61+
- `leverage` (number, required): New leverage value
62+
63+
#### `adjust_navi_margin`
64+
65+
Add or remove margin from a position.
5466

55-
### Supported Operations
67+
Parameters:
5668

57-
1. Trading Operations
69+
- `symbol` (string, required): Trading pair symbol
70+
- `amount` (number, required): Amount to add/remove
71+
- `is_add` (boolean, required): True for adding margin, false for removing
5872

59-
- Open positions with leverage
60-
- Close positions
61-
- Adjust position size
62-
- Modify leverage
63-
- Set stop loss and take profit
73+
### Market Data
6474

65-
2. Market Operations
75+
#### `get_navi_orderbook`
6676

67-
- Get market prices
68-
- View order book depth
69-
- Monitor funding rates
70-
- Track trading volume
71-
- View market statistics
77+
Get the orderbook for a trading pair.
7278

73-
3. Account Operations
74-
- View account positions
75-
- Monitor margin levels
76-
- Track realized/unrealized PnL
77-
- Manage collateral deposits/withdrawals
79+
Parameters:
7880

79-
### Configuration
81+
- `symbol` (string, required): Trading pair symbol
8082

81-
The Navi integration uses the following environment variables:
83+
#### `get_navi_market_data`
8284

83-
- `SUI_RPC_URL`: The Sui network RPC URL (defaults to mainnet)
84-
- `SUI_WALLET_ADDRESS`: The simulation account address
85+
Get market data for a trading pair.
8586

86-
### Error Handling
87+
Parameters:
8788

88-
All operations include comprehensive error handling and return standardized responses:
89+
- `symbol` (string, required): Trading pair symbol
90+
91+
### Account Management
92+
93+
#### `get_navi_account_info`
94+
95+
Get account information.
96+
97+
Parameters:
98+
99+
- `account_address` (string, required): Account address
100+
101+
## Usage Example
89102

90103
```typescript
91-
{
92-
reasoning: string;
93-
response: any;
94-
status: 'success' | 'error';
95-
query: string;
96-
errors: string[];
97-
}
104+
// Place a market order
105+
await tools.execute('place_navi_order', [
106+
'BTC-PERP', // symbol
107+
'BUY', // side
108+
'MARKET', // type
109+
1.0, // quantity
110+
]);
111+
112+
// Get account positions
113+
await tools.execute('get_navi_account_info', [
114+
'0x1234...', // account_address
115+
]);
98116
```
99117

100-
### Testing
118+
## Error Handling
101119

102-
Integration tests are available in `src/tests/navi.test.ts`. To run the tests:
120+
All tools return responses in a standardized format:
103121

104-
```bash
105-
npm test -- navi.test.ts
122+
```typescript
123+
{
124+
reasoning: string; // Description of what happened
125+
response: string; // The actual response data
126+
status: string; // "success" or "failure"
127+
query: string; // The original query
128+
errors: string[]; // Array of error messages if any
129+
}
106130
```
107131

108-
Make sure to set the required environment variables before running tests.
132+
## Dependencies
133+
134+
- @mysten/sui: ^1.1.0
135+
- Other Navi-specific dependencies

0 commit comments

Comments
 (0)