@imbingox/acex 0.3.0-beta.4 → 0.3.0-beta.6

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.
@@ -119,9 +119,10 @@ export interface RawPositionUpdate {
119
119
  }
120
120
 
121
121
  export interface RawRiskUpdate {
122
- equity?: string;
122
+ netEquity?: string;
123
+ riskEquity?: string;
123
124
  riskRatio?: string;
124
- actualLeverage?: string;
125
+ riskLeverage?: string;
125
126
  initialMargin?: string;
126
127
  maintenanceMargin?: string;
127
128
  exchangeTs?: number;
@@ -108,7 +108,7 @@ export function hasPrivateCredentials(
108
108
  venue?: Venue,
109
109
  ): boolean {
110
110
  if (venue === "juplend") {
111
- return Boolean(credentials?.apiKey);
111
+ return true;
112
112
  }
113
113
 
114
114
  return Boolean(credentials?.apiKey && credentials.secret);
@@ -467,7 +467,7 @@ export class PrivateSubscriptionCoordinator {
467
467
  account: RegisteredAccountRecord,
468
468
  ): Promise<void> {
469
469
  const credentials = account.credentials;
470
- if (!credentials) {
470
+ if (!credentials && record.venue !== "juplend") {
471
471
  throw new AcexError(
472
472
  "CREDENTIALS_MISSING",
473
473
  `Account credentials are required for private subscriptions: ${account.accountId}`,
@@ -476,7 +476,7 @@ export class PrivateSubscriptionCoordinator {
476
476
 
477
477
  const adapter = this.getAdapter(record.venue);
478
478
  const stream = adapter.createPrivateStream(
479
- credentials,
479
+ credentials ?? {},
480
480
  {
481
481
  onAccountSnapshot: (snapshot) => {
482
482
  if (!record.accountSubscribed) {
@@ -106,7 +106,10 @@ export class AcexClientImpl implements AcexClient, ClientContext {
106
106
  this.marketAdapters = new Map([[marketAdapter.venue, marketAdapter]]);
107
107
  const privateAdapters = [
108
108
  new BinancePrivateAdapter(),
109
- new JuplendPrivateAdapter(),
109
+ new JuplendPrivateAdapter(
110
+ options.account?.juplend?.rpcUrl,
111
+ options.account?.juplend?.jupApiKey,
112
+ ),
110
113
  ];
111
114
  this.privateAdapters = new Map(
112
115
  privateAdapters.map((adapter) => [adapter.venue, adapter]),
@@ -589,18 +589,22 @@ export class AccountManagerImpl
589
589
  return {
590
590
  accountId,
591
591
  venue,
592
- equity:
593
- input.equity === undefined
594
- ? previous?.equity
595
- : new BigNumber(input.equity),
592
+ netEquity:
593
+ input.netEquity === undefined
594
+ ? previous?.netEquity
595
+ : new BigNumber(input.netEquity),
596
+ riskEquity:
597
+ input.riskEquity === undefined
598
+ ? previous?.riskEquity
599
+ : new BigNumber(input.riskEquity),
596
600
  riskRatio:
597
601
  input.riskRatio === undefined
598
602
  ? previous?.riskRatio
599
603
  : new BigNumber(input.riskRatio),
600
- actualLeverage:
601
- input.actualLeverage === undefined
602
- ? previous?.actualLeverage
603
- : new BigNumber(input.actualLeverage),
604
+ riskLeverage:
605
+ input.riskLeverage === undefined
606
+ ? previous?.riskLeverage
607
+ : new BigNumber(input.riskLeverage),
604
608
  initialMargin:
605
609
  input.initialMargin === undefined
606
610
  ? previous?.initialMargin
@@ -101,6 +101,13 @@ export class OrderManagerImpl
101
101
  async subscribeOrders(input: SubscribeOrdersInput): Promise<void> {
102
102
  this.context.assertStarted();
103
103
  const account = this.context.getRegisteredAccount(input.accountId);
104
+ if (account.venue === "juplend") {
105
+ throw this.createError(
106
+ "VENUE_NOT_SUPPORTED",
107
+ `Venue does not support private order subscriptions: ${account.venue}`,
108
+ { accountId: input.accountId, venue: account.venue },
109
+ );
110
+ }
104
111
  this.context.ensurePrivateCredentials(input.accountId);
105
112
 
106
113
  const record = this.getOrCreateRecord(input.accountId, account.venue);
@@ -635,6 +642,7 @@ export class OrderManagerImpl
635
642
 
636
643
  private createError(
637
644
  code:
645
+ | "VENUE_NOT_SUPPORTED"
638
646
  | "ORDER_CANCEL_ALL_FAILED"
639
647
  | "ORDER_CANCEL_FAILED"
640
648
  | "ORDER_CREATE_FAILED"
@@ -91,9 +91,10 @@ export interface PositionSnapshot {
91
91
  export interface RiskSnapshot {
92
92
  accountId: string;
93
93
  venue: Venue;
94
- equity?: BigNumber;
94
+ netEquity?: BigNumber;
95
+ riskEquity?: BigNumber;
95
96
  riskRatio?: BigNumber;
96
- actualLeverage?: BigNumber;
97
+ riskLeverage?: BigNumber;
97
98
  initialMargin?: BigNumber;
98
99
  maintenanceMargin?: BigNumber;
99
100
  exchangeTs?: number;
@@ -41,6 +41,8 @@ export interface AccountRuntimeOptions {
41
41
  };
42
42
  juplend?: {
43
43
  pollIntervalMs?: number;
44
+ rpcUrl?: string;
45
+ jupApiKey?: string;
44
46
  };
45
47
  }
46
48
 
@@ -64,14 +66,17 @@ export interface BinanceAccountOptions {
64
66
  recvWindow?: number;
65
67
  }
66
68
 
67
- export interface JuplendAccountCredentials {
68
- apiKey: string;
69
- }
70
-
71
- export interface JuplendAccountOptions {
72
- walletAddress: string;
73
- positionId?: string;
74
- }
69
+ export type JuplendAccountOptions =
70
+ | {
71
+ walletAddress: string;
72
+ vaultId?: string;
73
+ positionId?: string;
74
+ }
75
+ | {
76
+ walletAddress?: string;
77
+ vaultId: string;
78
+ positionId: string;
79
+ };
75
80
 
76
81
  export interface RegisterCexAccountInput {
77
82
  accountId: string;
@@ -83,7 +88,7 @@ export interface RegisterCexAccountInput {
83
88
  export interface RegisterJuplendAccountInput {
84
89
  accountId: string;
85
90
  venue: "juplend";
86
- credentials: JuplendAccountCredentials;
91
+ credentials?: AccountCredentials;
87
92
  options: JuplendAccountOptions;
88
93
  }
89
94