@0xmonaco/core 0.7.9 → 0.8.4

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.
@@ -0,0 +1,10 @@
1
+ import type { CreateDelegatedSessionRequest, CreateDelegatedSessionResponse, DelegatedAgent, DelegatedAgentsAPI, ListDelegatedAgentsResponse, UpsertDelegatedAgentRequest } from "@0xmonaco/types";
2
+ import { BaseAPI } from "../base";
3
+ export declare class DelegatedAgentsAPIImpl extends BaseAPI implements DelegatedAgentsAPI {
4
+ upsertDelegatedAgent(request: UpsertDelegatedAgentRequest): Promise<DelegatedAgent>;
5
+ listDelegatedAgents(): Promise<ListDelegatedAgentsResponse>;
6
+ revokeDelegatedAgent(delegatedAgentId: string): Promise<{
7
+ status: "REVOKED";
8
+ }>;
9
+ createDelegatedSession(request: CreateDelegatedSessionRequest): Promise<CreateDelegatedSessionResponse>;
10
+ }
@@ -0,0 +1,38 @@
1
+ import { BaseAPI } from "../base";
2
+ import { perpRoutes } from "../perp";
3
+ export class DelegatedAgentsAPIImpl extends BaseAPI {
4
+ async upsertDelegatedAgent(request) {
5
+ return this.makeAuthenticatedRequest(perpRoutes.delegatedAgents.list(), {
6
+ method: "POST",
7
+ body: JSON.stringify({
8
+ agent_address: request.agentAddress,
9
+ name: request.name,
10
+ expires_at: request.expiresAt,
11
+ allowed_actions: request.allowedActions,
12
+ allowed_trading_pair_ids: request.allowedTradingPairIds,
13
+ allowed_margin_account_ids: request.allowedMarginAccountIds,
14
+ allowed_order_types: request.allowedOrderTypes,
15
+ allowed_time_in_force: request.allowedTimeInForce,
16
+ max_leverage: request.maxLeverage,
17
+ max_order_notional: request.maxOrderNotional,
18
+ max_open_orders: request.maxOpenOrders,
19
+ }),
20
+ });
21
+ }
22
+ async listDelegatedAgents() {
23
+ return this.makeAuthenticatedRequest(perpRoutes.delegatedAgents.list());
24
+ }
25
+ async revokeDelegatedAgent(delegatedAgentId) {
26
+ return this.makeAuthenticatedRequest(perpRoutes.delegatedAgents.byId(delegatedAgentId), {
27
+ method: "DELETE",
28
+ });
29
+ }
30
+ async createDelegatedSession(request) {
31
+ return this.makeAuthenticatedRequest(perpRoutes.delegatedAgents.sessions(), {
32
+ method: "POST",
33
+ body: JSON.stringify({
34
+ owner_user_id: request.ownerUserId,
35
+ }),
36
+ });
37
+ }
38
+ }
@@ -0,0 +1 @@
1
+ export * from "./api";
@@ -0,0 +1 @@
1
+ export * from "./api";
@@ -5,6 +5,7 @@
5
5
  */
6
6
  export * from "./applications/index";
7
7
  export * from "./base";
8
+ export * from "./delegated-agents";
8
9
  export * from "./fees";
9
10
  export * from "./margin-accounts";
10
11
  export * from "./market";
package/dist/api/index.js CHANGED
@@ -5,6 +5,7 @@
5
5
  */
6
6
  export * from "./applications/index";
7
7
  export * from "./base";
8
+ export * from "./delegated-agents";
8
9
  export * from "./fees";
9
10
  export * from "./margin-accounts";
10
11
  export * from "./market";
@@ -27,6 +27,11 @@ export declare const perpRoutes: {
27
27
  }) => string;
28
28
  readonly cancelConditional: (conditionalOrderId: string) => string;
29
29
  };
30
+ readonly delegatedAgents: {
31
+ readonly list: () => string;
32
+ readonly byId: (delegatedAgentId: string) => string;
33
+ readonly sessions: () => string;
34
+ };
30
35
  readonly market: {
31
36
  readonly listTradingPairs: (params?: {
32
37
  page?: number;
@@ -30,6 +30,11 @@ export const perpRoutes = {
30
30
  listConditional: (params) => withQuery(`${API_V1}/orders/conditional`, params),
31
31
  cancelConditional: (conditionalOrderId) => `${API_V1}/orders/conditional/${encodeSegment(conditionalOrderId)}`,
32
32
  },
33
+ delegatedAgents: {
34
+ list: () => `${API_V1}/delegated-agents`,
35
+ byId: (delegatedAgentId) => `${API_V1}/delegated-agents/${encodeSegment(delegatedAgentId)}`,
36
+ sessions: () => `${API_V1}/delegated-agents/sessions`,
37
+ },
33
38
  market: {
34
39
  listTradingPairs: (params) => withQuery(`${API_V1}/market/pairs`, params),
35
40
  getTradingPair: (tradingPairId) => `${API_V1}/market/pairs/${encodeSegment(tradingPairId)}`,
@@ -80,6 +80,7 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
80
80
  expirationDate?: string;
81
81
  timeInForce?: TimeInForce;
82
82
  marginAccountId?: string;
83
+ strategyKey?: string;
83
84
  positionSide?: PositionSide;
84
85
  leverage?: string;
85
86
  reduceOnly?: boolean;
@@ -131,6 +132,7 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
131
132
  tradingMode?: TradingMode;
132
133
  slippageTolerance?: number;
133
134
  marginAccountId?: string;
135
+ strategyKey?: string;
134
136
  positionSide?: PositionSide;
135
137
  leverage?: string;
136
138
  reduceOnly?: boolean;
@@ -107,6 +107,7 @@ export class TradingAPIImpl extends BaseAPI {
107
107
  expiration_date: options?.expirationDate,
108
108
  time_in_force: options?.timeInForce,
109
109
  margin_account_id: options?.marginAccountId,
110
+ strategy_key: options?.strategyKey,
110
111
  position_side: options?.positionSide,
111
112
  leverage: options?.leverage,
112
113
  reduce_only: options?.reduceOnly,
@@ -176,6 +177,7 @@ export class TradingAPIImpl extends BaseAPI {
176
177
  quantity,
177
178
  trading_mode: options?.tradingMode || "SPOT",
178
179
  margin_account_id: options?.marginAccountId,
180
+ strategy_key: options?.strategyKey,
179
181
  position_side: options?.positionSide,
180
182
  leverage: options?.leverage,
181
183
  reduce_only: options?.reduceOnly,
@@ -361,6 +363,7 @@ export class TradingAPIImpl extends BaseAPI {
361
363
  expiration_date: order.expirationDate,
362
364
  time_in_force: order.timeInForce,
363
365
  margin_account_id: order.marginAccountId,
366
+ strategy_key: order.strategyKey,
364
367
  position_side: order.positionSide,
365
368
  leverage: order.leverage,
366
369
  reduce_only: order.reduceOnly,
package/dist/sdk.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import type { ApplicationsAPI, AuthAPI, AuthState, FeesAPI, MarginAccountsAPI, MarketAPI, MonacoSDK, Network, PositionsAPI, ProfileAPI, SDKConfig, TradingAPI, VaultAPI } from "@0xmonaco/types";
1
+ import type { ApplicationsAPI, AuthAPI, AuthState, DelegatedAgentsAPI, FeesAPI, MarginAccountsAPI, MarketAPI, MonacoSDK, Network, PositionsAPI, ProfileAPI, SDKConfig, TradingAPI, VaultAPI } from "@0xmonaco/types";
2
2
  import { type PublicClient, type TransactionReceipt, type WalletClient } from "viem";
3
3
  import { type MonacoWebSocket, OrderbookAPIImpl, TradesAPIImpl } from "./api";
4
4
  export declare class MonacoSDKImpl implements MonacoSDK {
5
5
  auth: AuthAPI;
6
+ delegatedAgents: DelegatedAgentsAPI;
6
7
  applications: ApplicationsAPI;
7
8
  fees: FeesAPI;
8
9
  vault: VaultAPI;
package/dist/sdk.js CHANGED
@@ -3,6 +3,7 @@ import { createPublicClient, http } from "viem";
3
3
  import { sei, seiTestnet } from "viem/chains";
4
4
  import { ApplicationsAPIImpl, createMonacoWebSocket, OrderbookAPIImpl, TradesAPIImpl } from "./api";
5
5
  import { AuthAPIImpl } from "./api/auth";
6
+ import { DelegatedAgentsAPIImpl } from "./api/delegated-agents";
6
7
  import { FeesAPIImpl } from "./api/fees";
7
8
  import { MarginAccountsAPIImpl } from "./api/margin-accounts";
8
9
  import { MarketAPIImpl } from "./api/market";
@@ -14,6 +15,7 @@ import { APIError, InvalidConfigError, InvalidStateError } from "./errors";
14
15
  import { resolveApiUrl, resolveWsUrl } from "./networks";
15
16
  export class MonacoSDKImpl {
16
17
  auth;
18
+ delegatedAgents;
17
19
  applications;
18
20
  fees;
19
21
  vault;
@@ -35,6 +37,7 @@ export class MonacoSDKImpl {
35
37
  */
36
38
  propagateAccessToken(accessToken) {
37
39
  this.auth.setAccessToken(accessToken);
40
+ this.delegatedAgents.setAccessToken(accessToken);
38
41
  this.applications.setAccessToken(accessToken);
39
42
  this.fees.setAccessToken(accessToken);
40
43
  this.vault.setAccessToken(accessToken);
@@ -90,6 +93,7 @@ export class MonacoSDKImpl {
90
93
  this.marginAccounts = new MarginAccountsAPIImpl(apiUrl);
91
94
  this.positions = new PositionsAPIImpl(apiUrl);
92
95
  this.auth = new AuthAPIImpl(this.walletClient, this.chain, apiUrl);
96
+ this.delegatedAgents = new DelegatedAgentsAPIImpl(apiUrl);
93
97
  this.fees = new FeesAPIImpl(apiUrl);
94
98
  this.profile = new ProfileAPIImpl(apiUrl);
95
99
  this.vault = new VaultAPIImpl(this.publicClient, this.walletClient, this.chain, this.applications, this.profile, apiUrl);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xmonaco/core",
3
- "version": "0.7.9",
3
+ "version": "0.8.4",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,8 +23,8 @@
23
23
  "viem": "^2.45.2"
24
24
  },
25
25
  "dependencies": {
26
- "@0xmonaco/contracts": "0.7.9",
27
- "@0xmonaco/types": "0.7.9",
26
+ "@0xmonaco/contracts": "0.8.4",
27
+ "@0xmonaco/types": "0.8.4",
28
28
  "http-status-codes": "^2.3.0"
29
29
  },
30
30
  "devDependencies": {