|
1 | | -## Navi Protocol Integration |
| 1 | +# Navi Protocol Integration |
2 | 2 |
|
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. |
4 | 4 |
|
5 | | -### Features |
| 5 | +## Features |
6 | 6 |
|
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 |
8 | 25 |
|
9 | | -- Open and close positions |
10 | | -- Manage leverage and margin |
11 | | -- Monitor position metrics |
12 | | -- Track funding rates |
| 26 | +## Tools |
13 | 27 |
|
14 | | -#### Market Data |
| 28 | +### Order Management |
15 | 29 |
|
16 | | -- Get real-time prices |
17 | | -- View market statistics |
18 | | -- Monitor trading volume |
19 | | -- Track historical data |
| 30 | +#### `place_navi_order` |
20 | 31 |
|
21 | | -#### Account Management |
| 32 | +Place a new order on Navi. |
22 | 33 |
|
23 | | -- View account positions |
24 | | -- Monitor margin levels |
25 | | -- Track PnL |
26 | | -- Manage collateral |
| 34 | +Parameters: |
27 | 35 |
|
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 |
29 | 42 |
|
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. |
54 | 66 |
|
55 | | -### Supported Operations |
| 67 | +Parameters: |
56 | 68 |
|
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 |
58 | 72 |
|
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 |
64 | 74 |
|
65 | | -2. Market Operations |
| 75 | +#### `get_navi_orderbook` |
66 | 76 |
|
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. |
72 | 78 |
|
73 | | -3. Account Operations |
74 | | - - View account positions |
75 | | - - Monitor margin levels |
76 | | - - Track realized/unrealized PnL |
77 | | - - Manage collateral deposits/withdrawals |
| 79 | +Parameters: |
78 | 80 |
|
79 | | -### Configuration |
| 81 | +- `symbol` (string, required): Trading pair symbol |
80 | 82 |
|
81 | | -The Navi integration uses the following environment variables: |
| 83 | +#### `get_navi_market_data` |
82 | 84 |
|
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. |
85 | 86 |
|
86 | | -### Error Handling |
| 87 | +Parameters: |
87 | 88 |
|
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 |
89 | 102 |
|
90 | 103 | ```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 | +]); |
98 | 116 | ``` |
99 | 117 |
|
100 | | -### Testing |
| 118 | +## Error Handling |
101 | 119 |
|
102 | | -Integration tests are available in `src/tests/navi.test.ts`. To run the tests: |
| 120 | +All tools return responses in a standardized format: |
103 | 121 |
|
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 | +} |
106 | 130 | ``` |
107 | 131 |
|
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