@megatao/sdk 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +37 -0
- package/CHANGELOG.md +19 -0
- package/README.md +199 -0
- package/bin/alf +4 -0
- package/cli/README.md +198 -0
- package/cli/TEST_MANUAL.md +577 -0
- package/cli/commands/account.ts +545 -0
- package/cli/commands/funding.ts +481 -0
- package/cli/commands/liquidation.ts +523 -0
- package/cli/commands/market.ts +590 -0
- package/cli/commands/orders.ts +395 -0
- package/cli/commands/position.ts +1085 -0
- package/cli/commands/shared/positionUtils.ts +239 -0
- package/cli/commands/trading.ts +483 -0
- package/cli/commands/utils.ts +281 -0
- package/cli/commands/vault.ts +522 -0
- package/cli/index.ts +169 -0
- package/cli/interactive.ts +530 -0
- package/cli/utils/client.ts +457 -0
- package/cli/utils/config.ts +226 -0
- package/cli/utils/display.ts +258 -0
- package/cli/utils/index.ts +10 -0
- package/cli/utils/prompts.ts +364 -0
- package/config.example.json +23 -0
- package/dist/AlphaFuturesClient.d.ts +36 -0
- package/dist/AlphaFuturesClient.d.ts.map +1 -0
- package/dist/AlphaFuturesClient.js +116 -0
- package/dist/AlphaFuturesClient.js.map +1 -0
- package/dist/abi/Alpha.json +5987 -0
- package/dist/abi/abis.d.ts +319 -0
- package/dist/abi/abis.d.ts.map +1 -0
- package/dist/abi/abis.js +128 -0
- package/dist/abi/abis.js.map +1 -0
- package/dist/abi/index.d.ts +11 -0
- package/dist/abi/index.d.ts.map +1 -0
- package/dist/abi/index.js +15 -0
- package/dist/abi/index.js.map +1 -0
- package/dist/config/contracts.config.d.ts +70 -0
- package/dist/config/contracts.config.d.ts.map +1 -0
- package/dist/config/contracts.config.js +137 -0
- package/dist/config/contracts.config.js.map +1 -0
- package/dist/config/environments/alpha.config.d.ts +17 -0
- package/dist/config/environments/alpha.config.d.ts.map +1 -0
- package/dist/config/environments/alpha.config.js +140 -0
- package/dist/config/environments/alpha.config.js.map +1 -0
- package/dist/config/environments/beta.config.d.ts +16 -0
- package/dist/config/environments/beta.config.d.ts.map +1 -0
- package/dist/config/environments/beta.config.js +131 -0
- package/dist/config/environments/beta.config.js.map +1 -0
- package/dist/config/environments/dev.config.d.ts +13 -0
- package/dist/config/environments/dev.config.d.ts.map +1 -0
- package/dist/config/environments/dev.config.js +123 -0
- package/dist/config/environments/dev.config.js.map +1 -0
- package/dist/config/environments/index.d.ts +48 -0
- package/dist/config/environments/index.d.ts.map +1 -0
- package/dist/config/environments/index.js +81 -0
- package/dist/config/environments/index.js.map +1 -0
- package/dist/config/environments/localhost.config.d.ts +16 -0
- package/dist/config/environments/localhost.config.d.ts.map +1 -0
- package/dist/config/environments/localhost.config.js +152 -0
- package/dist/config/environments/localhost.config.js.map +1 -0
- package/dist/config/environments/prod.config.d.ts +20 -0
- package/dist/config/environments/prod.config.d.ts.map +1 -0
- package/dist/config/environments/prod.config.js +143 -0
- package/dist/config/environments/prod.config.js.map +1 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +41 -0
- package/dist/config/index.js.map +1 -0
- package/dist/constants/assets.d.ts +76 -0
- package/dist/constants/assets.d.ts.map +1 -0
- package/dist/constants/assets.js +277 -0
- package/dist/constants/assets.js.map +1 -0
- package/dist/constants/contracts.d.ts +41 -0
- package/dist/constants/contracts.d.ts.map +1 -0
- package/dist/constants/contracts.js +57 -0
- package/dist/constants/contracts.js.map +1 -0
- package/dist/constants/index.d.ts +36 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +75 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/networks.d.ts +32 -0
- package/dist/constants/networks.d.ts.map +1 -0
- package/dist/constants/networks.js +174 -0
- package/dist/constants/networks.js.map +1 -0
- package/dist/contracts/index.d.ts +5 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +21 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/viem/AlphaViem.d.ts +518 -0
- package/dist/contracts/viem/AlphaViem.d.ts.map +1 -0
- package/dist/contracts/viem/AlphaViem.js +1287 -0
- package/dist/contracts/viem/AlphaViem.js.map +1 -0
- package/dist/contracts/viem/PriceOracleViem.d.ts +71 -0
- package/dist/contracts/viem/PriceOracleViem.d.ts.map +1 -0
- package/dist/contracts/viem/PriceOracleViem.js +212 -0
- package/dist/contracts/viem/PriceOracleViem.js.map +1 -0
- package/dist/contracts/viem/index.d.ts +9 -0
- package/dist/contracts/viem/index.d.ts.map +1 -0
- package/dist/contracts/viem/index.js +17 -0
- package/dist/contracts/viem/index.js.map +1 -0
- package/dist/errors/index.d.ts +44 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +83 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/dist/types/alpha.d.ts +299 -0
- package/dist/types/alpha.d.ts.map +1 -0
- package/dist/types/alpha.js +6 -0
- package/dist/types/alpha.js.map +1 -0
- package/dist/types/client.d.ts +24 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/client.js +13 -0
- package/dist/types/client.js.map +1 -0
- package/dist/types/contracts.d.ts +48 -0
- package/dist/types/contracts.d.ts.map +1 -0
- package/dist/types/contracts.js +6 -0
- package/dist/types/contracts.js.map +1 -0
- package/dist/types/funding.d.ts +27 -0
- package/dist/types/funding.d.ts.map +1 -0
- package/dist/types/funding.js +6 -0
- package/dist/types/funding.js.map +1 -0
- package/dist/types/index.d.ts +92 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +47 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/liquidation.d.ts +20 -0
- package/dist/types/liquidation.d.ts.map +1 -0
- package/dist/types/liquidation.js +6 -0
- package/dist/types/liquidation.js.map +1 -0
- package/dist/types/margin.d.ts +29 -0
- package/dist/types/margin.d.ts.map +1 -0
- package/dist/types/margin.js +6 -0
- package/dist/types/margin.js.map +1 -0
- package/dist/types/oracle.d.ts +21 -0
- package/dist/types/oracle.d.ts.map +1 -0
- package/dist/types/oracle.js +6 -0
- package/dist/types/oracle.js.map +1 -0
- package/dist/types/positions.d.ts +43 -0
- package/dist/types/positions.d.ts.map +1 -0
- package/dist/types/positions.js +13 -0
- package/dist/types/positions.js.map +1 -0
- package/dist/utils/calculations.d.ts +84 -0
- package/dist/utils/calculations.d.ts.map +1 -0
- package/dist/utils/calculations.js +155 -0
- package/dist/utils/calculations.js.map +1 -0
- package/dist/utils/errors.d.ts +24 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +129 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/events.d.ts +40 -0
- package/dist/utils/events.d.ts.map +1 -0
- package/dist/utils/events.js +73 -0
- package/dist/utils/events.js.map +1 -0
- package/dist/utils/format.d.ts +40 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +86 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +26 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/network.d.ts +52 -0
- package/dist/utils/network.d.ts.map +1 -0
- package/dist/utils/network.js +192 -0
- package/dist/utils/network.js.map +1 -0
- package/dist/utils/positionCalculations.d.ts +145 -0
- package/dist/utils/positionCalculations.d.ts.map +1 -0
- package/dist/utils/positionCalculations.js +278 -0
- package/dist/utils/positionCalculations.js.map +1 -0
- package/dist/utils/validation.d.ts +28 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +68 -0
- package/dist/utils/validation.js.map +1 -0
- package/docs/README.md +40 -0
- package/docs/api/API.md +831 -0
- package/docs/guides/GETTING_STARTED.md +316 -0
- package/docs/guides/TRADING_GUIDE.md +677 -0
- package/docs/integration/INTEGRATION_GUIDE.md +1679 -0
- package/docs/integration/VIEM_INTEGRATION.md +294 -0
- package/docs/reference/CLI_QUICK_REFERENCE.md +197 -0
- package/docs/reference/TROUBLESHOOTING.md +922 -0
- package/package.json +113 -0
- package/src/AlphaFuturesClient.ts +158 -0
- package/src/abi/.gitkeep +1 -0
- package/src/abi/Alpha.json +5987 -0
- package/src/abi/README.md +99 -0
- package/src/abi/abis.ts +131 -0
- package/src/abi/index.ts +13 -0
- package/src/config/contracts.config.ts +186 -0
- package/src/config/environments/alpha.config.ts +139 -0
- package/src/config/environments/beta.config.ts +130 -0
- package/src/config/environments/dev.config.ts +122 -0
- package/src/config/environments/index.ts +87 -0
- package/src/config/environments/localhost.config.ts +153 -0
- package/src/config/environments/prod.config.ts +142 -0
- package/src/config/index.ts +29 -0
- package/src/constants/assets.ts +299 -0
- package/src/constants/contracts.ts +64 -0
- package/src/constants/index.ts +69 -0
- package/src/constants/networks.ts +182 -0
- package/src/contracts/index.ts +5 -0
- package/src/contracts/viem/AlphaViem.ts +1615 -0
- package/src/contracts/viem/PriceOracleViem.ts +272 -0
- package/src/contracts/viem/index.ts +11 -0
- package/src/errors/index.ts +87 -0
- package/src/index.ts +59 -0
- package/src/types/VIEM_TYPES_README.md +70 -0
- package/src/types/alpha.ts +358 -0
- package/src/types/client.ts +27 -0
- package/src/types/contracts.ts +74 -0
- package/src/types/funding.ts +31 -0
- package/src/types/index.ts +108 -0
- package/src/types/liquidation.ts +23 -0
- package/src/types/margin.ts +34 -0
- package/src/types/oracle.ts +24 -0
- package/src/types/positions.ts +48 -0
- package/src/utils/calculations.ts +175 -0
- package/src/utils/errors.ts +147 -0
- package/src/utils/events.ts +98 -0
- package/src/utils/format.ts +84 -0
- package/src/utils/index.ts +10 -0
- package/src/utils/network.ts +212 -0
- package/src/utils/positionCalculations.ts +317 -0
- package/src/utils/validation.ts +76 -0
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
# Manual CLI Testing Guide
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
This guide provides comprehensive manual testing procedures for the Alpha Futures CLI, focusing on the collateral-first position opening paradigm and backward compatibility with the size-first paradigm.
|
|
5
|
+
|
|
6
|
+
## Prerequisites
|
|
7
|
+
|
|
8
|
+
1. **Environment Setup**
|
|
9
|
+
```bash
|
|
10
|
+
cd /Users/er/Documents/Projects/ALPHA/alpha-futures/sdk
|
|
11
|
+
npm install
|
|
12
|
+
npm run build
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
2. **Configuration**
|
|
16
|
+
- Ensure `.env` file exists with valid RPC URL and private key
|
|
17
|
+
- Verify wallet has sufficient TAO balance
|
|
18
|
+
- Confirm contracts are deployed and addresses are correct
|
|
19
|
+
|
|
20
|
+
3. **Check Current State**
|
|
21
|
+
```bash
|
|
22
|
+
# View your wallet balance
|
|
23
|
+
npm run cli -- balance
|
|
24
|
+
|
|
25
|
+
# View existing positions
|
|
26
|
+
npm run cli -- position list
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Test Suite 1: Collateral-First Paradigm (New)
|
|
30
|
+
|
|
31
|
+
### Test 1.1: Basic Long Position with Fractional Leverage
|
|
32
|
+
**Objective:** Open a long position using collateral-first paradigm with fractional leverage
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm run cli -- position open \
|
|
36
|
+
--asset BITMIND \
|
|
37
|
+
--direction long \
|
|
38
|
+
--collateral 100 \
|
|
39
|
+
--leverage 3.5 \
|
|
40
|
+
--yes
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Expected Result:**
|
|
44
|
+
- Position opens successfully
|
|
45
|
+
- Position size: ~18,421 BITMIND tokens (at $0.019 price)
|
|
46
|
+
- Position value: $350 (100 * 3.5)
|
|
47
|
+
- Leverage: 3.5x
|
|
48
|
+
- Success message displayed
|
|
49
|
+
|
|
50
|
+
**Verification:**
|
|
51
|
+
```bash
|
|
52
|
+
npm run cli -- position list
|
|
53
|
+
npm run cli -- position status <position-id>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Test 1.2: Short Position with Fractional Leverage
|
|
57
|
+
**Objective:** Open a short position with fractional leverage
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npm run cli -- position open \
|
|
61
|
+
--asset BITMIND \
|
|
62
|
+
--direction short \
|
|
63
|
+
--collateral 50 \
|
|
64
|
+
--leverage 2.7 \
|
|
65
|
+
--yes
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Expected Result:**
|
|
69
|
+
- Short position opens successfully
|
|
70
|
+
- Position size calculated based on collateral * leverage / price
|
|
71
|
+
- Leverage: 2.7x
|
|
72
|
+
- Direction: SHORT
|
|
73
|
+
|
|
74
|
+
### Test 1.3: Minimum Collateral Trade
|
|
75
|
+
**Objective:** Test minimum viable collateral amount
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
npm run cli -- position open \
|
|
79
|
+
--asset BITMIND \
|
|
80
|
+
--direction long \
|
|
81
|
+
--collateral 0.01 \
|
|
82
|
+
--leverage 1.0 \
|
|
83
|
+
--yes
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Expected Result:**
|
|
87
|
+
- Position opens with minimum collateral (0.01 TAO)
|
|
88
|
+
- Position size calculated correctly
|
|
89
|
+
- No errors or warnings
|
|
90
|
+
|
|
91
|
+
### Test 1.4: Maximum Leverage Trade
|
|
92
|
+
**Objective:** Test maximum allowed leverage (30x)
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
npm run cli -- position open \
|
|
96
|
+
--asset BITMIND \
|
|
97
|
+
--direction long \
|
|
98
|
+
--collateral 10 \
|
|
99
|
+
--leverage 30 \
|
|
100
|
+
--yes
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Expected Result:**
|
|
104
|
+
- Position opens successfully
|
|
105
|
+
- Warning about high leverage risk displayed
|
|
106
|
+
- Leverage: 30x
|
|
107
|
+
- Position value: $300 (10 * 30)
|
|
108
|
+
|
|
109
|
+
### Test 1.5: Default Leverage (3x)
|
|
110
|
+
**Objective:** Test that default leverage is applied when not specified
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
npm run cli -- position open \
|
|
114
|
+
--asset BITMIND \
|
|
115
|
+
--direction long \
|
|
116
|
+
--collateral 25 \
|
|
117
|
+
--yes
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Expected Result:**
|
|
121
|
+
- Position opens with 3x default leverage
|
|
122
|
+
- Position value: $75 (25 * 3)
|
|
123
|
+
- No leverage specified in command output
|
|
124
|
+
|
|
125
|
+
### Test 1.6: All Valid Fractional Leverage Increments
|
|
126
|
+
**Objective:** Test various fractional leverage values (0.1x increments)
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Test 1.1x
|
|
130
|
+
npm run cli -- position open --asset BITMIND --direction long --collateral 10 --leverage 1.1 --yes
|
|
131
|
+
|
|
132
|
+
# Test 5.5x
|
|
133
|
+
npm run cli -- position open --asset BITMIND --direction long --collateral 10 --leverage 5.5 --yes
|
|
134
|
+
|
|
135
|
+
# Test 10.7x
|
|
136
|
+
npm run cli -- position open --asset BITMIND --direction long --collateral 10 --leverage 10.7 --yes
|
|
137
|
+
|
|
138
|
+
# Test 29.9x
|
|
139
|
+
npm run cli -- position open --asset BITMIND --direction long --collateral 10 --leverage 29.9 --yes
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Expected Result:**
|
|
143
|
+
- All positions open successfully
|
|
144
|
+
- Each leverage value is accepted and applied correctly
|
|
145
|
+
|
|
146
|
+
### Test 1.7: Interactive Mode
|
|
147
|
+
**Objective:** Test interactive position opening
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
npm run cli -- position open --asset BITMIND --interactive
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Steps:**
|
|
154
|
+
1. Select direction: LONG
|
|
155
|
+
2. Enter collateral: 50
|
|
156
|
+
3. Enter leverage: 3.5
|
|
157
|
+
4. Confirm trade
|
|
158
|
+
|
|
159
|
+
**Expected Result:**
|
|
160
|
+
- Interactive prompts work correctly
|
|
161
|
+
- Position parameters calculated and displayed
|
|
162
|
+
- Position opens after confirmation
|
|
163
|
+
|
|
164
|
+
## Test Suite 2: Error Cases and Validation
|
|
165
|
+
|
|
166
|
+
### Test 2.1: Collateral Below Minimum
|
|
167
|
+
**Objective:** Verify rejection of collateral below 0.01
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
npm run cli -- position open \
|
|
171
|
+
--asset BITMIND \
|
|
172
|
+
--direction long \
|
|
173
|
+
--collateral 0.001 \
|
|
174
|
+
--leverage 3.5 \
|
|
175
|
+
--yes
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**Expected Result:**
|
|
179
|
+
- ERROR: "Collateral must be at least 0.01 TAO"
|
|
180
|
+
- Position NOT opened
|
|
181
|
+
- Clear error message displayed
|
|
182
|
+
|
|
183
|
+
### Test 2.2: Invalid Leverage Precision
|
|
184
|
+
**Objective:** Verify rejection of non-0.1x increments
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
npm run cli -- position open \
|
|
188
|
+
--asset BITMIND \
|
|
189
|
+
--direction long \
|
|
190
|
+
--collateral 100 \
|
|
191
|
+
--leverage 3.14 \
|
|
192
|
+
--yes
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Expected Result:**
|
|
196
|
+
- ERROR: "Leverage must be in 0.1x increments"
|
|
197
|
+
- Position NOT opened
|
|
198
|
+
- Suggestion to use valid increments
|
|
199
|
+
|
|
200
|
+
### Test 2.3: Leverage Below Minimum
|
|
201
|
+
**Objective:** Verify rejection of leverage < 1.0x
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
npm run cli -- position open \
|
|
205
|
+
--asset BITMIND \
|
|
206
|
+
--direction long \
|
|
207
|
+
--collateral 100 \
|
|
208
|
+
--leverage 0.5 \
|
|
209
|
+
--yes
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**Expected Result:**
|
|
213
|
+
- ERROR: "Leverage must be at least 1.0x"
|
|
214
|
+
- Position NOT opened
|
|
215
|
+
|
|
216
|
+
### Test 2.4: Leverage Above Maximum
|
|
217
|
+
**Objective:** Verify rejection of leverage > 30x
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
npm run cli -- position open \
|
|
221
|
+
--asset BITMIND \
|
|
222
|
+
--direction long \
|
|
223
|
+
--collateral 100 \
|
|
224
|
+
--leverage 35 \
|
|
225
|
+
--yes
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
**Expected Result:**
|
|
229
|
+
- ERROR: "Leverage cannot exceed 30x"
|
|
230
|
+
- Position NOT opened
|
|
231
|
+
|
|
232
|
+
### Test 2.5: Zero Collateral
|
|
233
|
+
**Objective:** Verify rejection of zero collateral
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
npm run cli -- position open \
|
|
237
|
+
--asset BITMIND \
|
|
238
|
+
--direction long \
|
|
239
|
+
--collateral 0 \
|
|
240
|
+
--leverage 3.5 \
|
|
241
|
+
--yes
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**Expected Result:**
|
|
245
|
+
- ERROR: "Collateral must be greater than zero"
|
|
246
|
+
- Position NOT opened
|
|
247
|
+
|
|
248
|
+
### Test 2.6: Negative Collateral
|
|
249
|
+
**Objective:** Verify rejection of negative collateral
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
npm run cli -- position open \
|
|
253
|
+
--asset BITMIND \
|
|
254
|
+
--direction long \
|
|
255
|
+
--collateral -100 \
|
|
256
|
+
--leverage 3.5 \
|
|
257
|
+
--yes
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**Expected Result:**
|
|
261
|
+
- ERROR: Invalid collateral value
|
|
262
|
+
- Position NOT opened
|
|
263
|
+
|
|
264
|
+
### Test 2.7: Insufficient Balance
|
|
265
|
+
**Objective:** Verify rejection when collateral exceeds balance
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
npm run cli -- position open \
|
|
269
|
+
--asset BITMIND \
|
|
270
|
+
--direction long \
|
|
271
|
+
--collateral 999999999 \
|
|
272
|
+
--leverage 3.5 \
|
|
273
|
+
--yes
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
**Expected Result:**
|
|
277
|
+
- ERROR: "Insufficient balance"
|
|
278
|
+
- Current balance displayed
|
|
279
|
+
- Position NOT opened
|
|
280
|
+
|
|
281
|
+
### Test 2.8: Mixed Paradigms (Should Fail)
|
|
282
|
+
**Objective:** Verify error when mixing collateral and size parameters
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
npm run cli -- position open \
|
|
286
|
+
--asset BITMIND \
|
|
287
|
+
--direction long \
|
|
288
|
+
--collateral 100 \
|
|
289
|
+
--size 30 \
|
|
290
|
+
--yes
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
**Expected Result:**
|
|
294
|
+
- ERROR: "Cannot mix collateral-first and size-first parameters"
|
|
295
|
+
- Clear explanation of which paradigm to use
|
|
296
|
+
- Position NOT opened
|
|
297
|
+
|
|
298
|
+
## Test Suite 3: Size-First Paradigm (Backward Compatibility)
|
|
299
|
+
|
|
300
|
+
### Test 3.1: Legacy Size and Margin Command
|
|
301
|
+
**Objective:** Verify backward compatibility with size-first paradigm
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
npm run cli -- position open \
|
|
305
|
+
--asset BITMIND \
|
|
306
|
+
--direction long \
|
|
307
|
+
--size 30 \
|
|
308
|
+
--margin 10 \
|
|
309
|
+
--yes
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
**Expected Result:**
|
|
313
|
+
- Position opens successfully
|
|
314
|
+
- Uses size-first calculation method
|
|
315
|
+
- Position size: 30 tokens
|
|
316
|
+
- Margin: 10 TAO
|
|
317
|
+
- Leverage calculated as size/margin
|
|
318
|
+
|
|
319
|
+
### Test 3.2: Legacy Command with Default Margin
|
|
320
|
+
**Objective:** Test size-first with default margin calculation
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
npm run cli -- position open \
|
|
324
|
+
--asset BITMIND \
|
|
325
|
+
--direction long \
|
|
326
|
+
--size 50 \
|
|
327
|
+
--yes
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
**Expected Result:**
|
|
331
|
+
- Position opens successfully
|
|
332
|
+
- Margin calculated from size and default leverage
|
|
333
|
+
- Works as before (backward compatible)
|
|
334
|
+
|
|
335
|
+
## Test Suite 4: Advanced Scenarios
|
|
336
|
+
|
|
337
|
+
### Test 4.1: High Leverage Warning Display
|
|
338
|
+
**Objective:** Verify warning is shown for leverage > 20x
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
npm run cli -- position open \
|
|
342
|
+
--asset BITMIND \
|
|
343
|
+
--direction long \
|
|
344
|
+
--collateral 100 \
|
|
345
|
+
--leverage 25
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
**Expected Result:**
|
|
349
|
+
- WARNING displayed: "High leverage (25x) increases liquidation risk"
|
|
350
|
+
- User prompted for confirmation (if not using --yes flag)
|
|
351
|
+
- Position opens after confirmation
|
|
352
|
+
|
|
353
|
+
### Test 4.2: Multiple Positions with Different Leverage
|
|
354
|
+
**Objective:** Open multiple positions with varying leverage
|
|
355
|
+
|
|
356
|
+
```bash
|
|
357
|
+
# Conservative position
|
|
358
|
+
npm run cli -- position open --asset BITMIND --direction long --collateral 100 --leverage 2.0 --yes
|
|
359
|
+
|
|
360
|
+
# Moderate position
|
|
361
|
+
npm run cli -- position open --asset BITMIND --direction long --collateral 100 --leverage 5.0 --yes
|
|
362
|
+
|
|
363
|
+
# Aggressive position
|
|
364
|
+
npm run cli -- position open --asset BITMIND --direction long --collateral 100 --leverage 15.0 --yes
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
**Expected Result:**
|
|
368
|
+
- All three positions open successfully
|
|
369
|
+
- Each has distinct leverage
|
|
370
|
+
- List command shows all positions
|
|
371
|
+
|
|
372
|
+
### Test 4.3: Small Token Price Handling
|
|
373
|
+
**Objective:** Test with very small token prices
|
|
374
|
+
|
|
375
|
+
```bash
|
|
376
|
+
# Assuming a low-priced token
|
|
377
|
+
npm run cli -- position open \
|
|
378
|
+
--asset <LOW_PRICE_TOKEN> \
|
|
379
|
+
--direction long \
|
|
380
|
+
--collateral 100 \
|
|
381
|
+
--leverage 5.0 \
|
|
382
|
+
--yes
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
**Expected Result:**
|
|
386
|
+
- Large position size calculated correctly
|
|
387
|
+
- No overflow errors
|
|
388
|
+
- Position opens successfully
|
|
389
|
+
|
|
390
|
+
### Test 4.4: Large Collateral Amount
|
|
391
|
+
**Objective:** Test with large collateral values
|
|
392
|
+
|
|
393
|
+
```bash
|
|
394
|
+
npm run cli -- position open \
|
|
395
|
+
--asset BITMIND \
|
|
396
|
+
--direction long \
|
|
397
|
+
--collateral 10000 \
|
|
398
|
+
--leverage 10 \
|
|
399
|
+
--yes
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
**Expected Result:**
|
|
403
|
+
- Position opens successfully
|
|
404
|
+
- Large position size calculated correctly
|
|
405
|
+
- No precision loss
|
|
406
|
+
|
|
407
|
+
### Test 4.5: Rapid Sequential Positions
|
|
408
|
+
**Objective:** Test opening multiple positions quickly
|
|
409
|
+
|
|
410
|
+
```bash
|
|
411
|
+
for i in {1..5}; do
|
|
412
|
+
npm run cli -- position open \
|
|
413
|
+
--asset BITMIND \
|
|
414
|
+
--direction long \
|
|
415
|
+
--collateral 10 \
|
|
416
|
+
--leverage 3.0 \
|
|
417
|
+
--yes
|
|
418
|
+
done
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
**Expected Result:**
|
|
422
|
+
- All 5 positions open successfully
|
|
423
|
+
- No race conditions or conflicts
|
|
424
|
+
- Each position has unique ID
|
|
425
|
+
|
|
426
|
+
## Test Suite 5: Position Management
|
|
427
|
+
|
|
428
|
+
### Test 5.1: View Position Details
|
|
429
|
+
**Objective:** Verify position details display correctly
|
|
430
|
+
|
|
431
|
+
```bash
|
|
432
|
+
# Open a position first
|
|
433
|
+
npm run cli -- position open --asset BITMIND --direction long --collateral 100 --leverage 3.5 --yes
|
|
434
|
+
|
|
435
|
+
# View details
|
|
436
|
+
npm run cli -- position status <position-id>
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
**Expected Result:**
|
|
440
|
+
- Position details displayed:
|
|
441
|
+
- Position ID
|
|
442
|
+
- Asset
|
|
443
|
+
- Direction (LONG/SHORT)
|
|
444
|
+
- Collateral: 100 TAO
|
|
445
|
+
- Leverage: 3.5x
|
|
446
|
+
- Position size in tokens
|
|
447
|
+
- Entry price
|
|
448
|
+
- Current P&L
|
|
449
|
+
|
|
450
|
+
### Test 5.2: Close Position
|
|
451
|
+
**Objective:** Close a position and verify settlement
|
|
452
|
+
|
|
453
|
+
```bash
|
|
454
|
+
# Close the position
|
|
455
|
+
npm run cli -- position close <position-id> --yes
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
**Expected Result:**
|
|
459
|
+
- Position closes successfully
|
|
460
|
+
- P&L calculated and displayed
|
|
461
|
+
- Balance updated accordingly
|
|
462
|
+
- Position removed from list
|
|
463
|
+
|
|
464
|
+
### Test 5.3: List All Positions
|
|
465
|
+
**Objective:** Verify position list display
|
|
466
|
+
|
|
467
|
+
```bash
|
|
468
|
+
npm run cli -- position list
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
**Expected Result:**
|
|
472
|
+
- Table showing all open positions
|
|
473
|
+
- Columns: ID, Asset, Direction, Collateral, Leverage, Size, Entry Price, P&L
|
|
474
|
+
- Accurate and up-to-date information
|
|
475
|
+
|
|
476
|
+
## Test Suite 6: Help and Documentation
|
|
477
|
+
|
|
478
|
+
### Test 6.1: Command Help
|
|
479
|
+
**Objective:** Verify help messages are accurate
|
|
480
|
+
|
|
481
|
+
```bash
|
|
482
|
+
npm run cli -- position open --help
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
**Expected Result:**
|
|
486
|
+
- Help text displayed
|
|
487
|
+
- Shows both collateral-first and size-first options
|
|
488
|
+
- Examples provided
|
|
489
|
+
- Clear descriptions
|
|
490
|
+
|
|
491
|
+
### Test 6.2: Version Check
|
|
492
|
+
**Objective:** Verify version information
|
|
493
|
+
|
|
494
|
+
```bash
|
|
495
|
+
npm run cli -- --version
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
**Expected Result:**
|
|
499
|
+
- Current version displayed
|
|
500
|
+
- Matches package.json version
|
|
501
|
+
|
|
502
|
+
## Post-Test Cleanup
|
|
503
|
+
|
|
504
|
+
After completing tests:
|
|
505
|
+
|
|
506
|
+
```bash
|
|
507
|
+
# Close all open positions
|
|
508
|
+
npm run cli -- position list
|
|
509
|
+
npm run cli -- position close <position-id-1> --yes
|
|
510
|
+
npm run cli -- position close <position-id-2> --yes
|
|
511
|
+
# ... repeat for all positions
|
|
512
|
+
|
|
513
|
+
# Verify all closed
|
|
514
|
+
npm run cli -- position list
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
## Test Results Template
|
|
518
|
+
|
|
519
|
+
For each test, record:
|
|
520
|
+
|
|
521
|
+
| Test ID | Test Name | Status | Notes |
|
|
522
|
+
|---------|-----------|--------|-------|
|
|
523
|
+
| 1.1 | Basic Long Position | ✅ PASS | Position opened with correct params |
|
|
524
|
+
| 1.2 | Short Position | ✅ PASS | - |
|
|
525
|
+
| ... | ... | ... | ... |
|
|
526
|
+
|
|
527
|
+
## Common Issues and Troubleshooting
|
|
528
|
+
|
|
529
|
+
### Issue: "Insufficient allowance"
|
|
530
|
+
**Solution:** Approve TAO spending first
|
|
531
|
+
```bash
|
|
532
|
+
npm run cli -- approve <amount>
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
### Issue: "Transaction reverted"
|
|
536
|
+
**Check:**
|
|
537
|
+
- Sufficient balance
|
|
538
|
+
- Contract not paused
|
|
539
|
+
- Valid asset address
|
|
540
|
+
- Network connectivity
|
|
541
|
+
|
|
542
|
+
### Issue: "Price unavailable"
|
|
543
|
+
**Check:**
|
|
544
|
+
- Oracle is functioning
|
|
545
|
+
- Asset is configured
|
|
546
|
+
- Network connectivity
|
|
547
|
+
|
|
548
|
+
### Issue: Command not found
|
|
549
|
+
**Solution:** Ensure you're in the SDK directory and have run `npm install`
|
|
550
|
+
|
|
551
|
+
## Success Criteria
|
|
552
|
+
|
|
553
|
+
All tests should:
|
|
554
|
+
- ✅ Execute without unexpected errors
|
|
555
|
+
- ✅ Produce expected results
|
|
556
|
+
- ✅ Display clear messages
|
|
557
|
+
- ✅ Handle edge cases gracefully
|
|
558
|
+
- ✅ Maintain backward compatibility
|
|
559
|
+
|
|
560
|
+
## Reporting Issues
|
|
561
|
+
|
|
562
|
+
If any test fails, report:
|
|
563
|
+
1. Test ID and name
|
|
564
|
+
2. Command used
|
|
565
|
+
3. Expected result
|
|
566
|
+
4. Actual result
|
|
567
|
+
5. Error messages (if any)
|
|
568
|
+
6. Environment details (Node version, OS, network)
|
|
569
|
+
|
|
570
|
+
## Notes
|
|
571
|
+
|
|
572
|
+
- Always test on testnet first
|
|
573
|
+
- Keep test amounts small to minimize costs
|
|
574
|
+
- Monitor gas prices during testing
|
|
575
|
+
- Record transaction hashes for debugging
|
|
576
|
+
- Test with multiple wallets if possible
|
|
577
|
+
- Verify calculations independently
|