@metamask-previews/perps-controller 15.0.0-preview-e3275932a → 15.0.0-preview-99421bfe4
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/README.md +33 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,22 +12,42 @@ or
|
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
|
+
`PerpsController` provides a provider-agnostic API for perpetual trading. It
|
|
16
|
+
normalizes market data, account state, trading, funding, transfers, risk
|
|
17
|
+
calculations, and live subscriptions across enabled providers.
|
|
18
|
+
|
|
19
|
+
Applications construct the controller with a messenger and their
|
|
20
|
+
platform-specific dependencies:
|
|
21
|
+
|
|
15
22
|
```typescript
|
|
16
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
PerpsController,
|
|
25
|
+
type PerpsControllerOptions,
|
|
26
|
+
} from '@metamask/perps-controller';
|
|
27
|
+
|
|
28
|
+
export async function createPerpsController(
|
|
29
|
+
options: PerpsControllerOptions,
|
|
30
|
+
): Promise<PerpsController> {
|
|
31
|
+
const controller = new PerpsController(options);
|
|
32
|
+
await controller.init();
|
|
33
|
+
return controller;
|
|
34
|
+
}
|
|
17
35
|
```
|
|
18
36
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
The controller registers its public operations as `PerpsController:*`
|
|
38
|
+
messenger actions, and clients can call the same methods directly. Its main
|
|
39
|
+
capabilities are:
|
|
40
|
+
|
|
41
|
+
- Provider and network lifecycle management.
|
|
42
|
+
- Normalized market, account, position, order, and history reads.
|
|
43
|
+
- Trading, position, margin, deposit, and withdrawal operations with
|
|
44
|
+
preflight validation and risk calculations.
|
|
45
|
+
- Callback-based live prices, positions, orders, fills, order books, and
|
|
46
|
+
candles. Each subscription returns an unsubscribe function.
|
|
47
|
+
|
|
48
|
+
The package exports the controller's parameter, result, provider, and
|
|
49
|
+
messenger types for client integrations. Provider availability and aggregated
|
|
50
|
+
routing are controlled by client configuration and feature flags.
|
|
31
51
|
|
|
32
52
|
## Contributing
|
|
33
53
|
|
package/package.json
CHANGED