@kodiak-finance/orderly-hooks 2.8.10-rc.1 → 2.8.10-rc.2

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/dist/index.mjs CHANGED
@@ -115,20 +115,20 @@ var useAccountInstance = () => {
115
115
  "keyStore is not defined, please use OrderlyProvider and provide keyStore"
116
116
  );
117
117
  }
118
- const account10 = useConstant(() => {
119
- let account11 = SimpleDI.get("account");
120
- if (!account11) {
121
- account11 = new Account(
118
+ const account9 = useConstant(() => {
119
+ let account10 = SimpleDI.get("account");
120
+ if (!account10) {
121
+ account10 = new Account(
122
122
  configStore,
123
123
  keyStore,
124
124
  // getWalletAdapter,
125
125
  walletAdapters
126
126
  );
127
- SimpleDI.registerByName("account", account11);
127
+ SimpleDI.registerByName("account", account10);
128
128
  }
129
- return account11;
129
+ return account10;
130
130
  });
131
- return account10;
131
+ return account9;
132
132
  };
133
133
 
134
134
  // src/useMutation.ts
@@ -154,7 +154,7 @@ var useMutation = (url, method = "POST", options) => {
154
154
  if (!url.startsWith("http")) {
155
155
  fullUrl = `${apiBaseUrl}${url}`;
156
156
  }
157
- const account10 = useAccountInstance();
157
+ const account9 = useAccountInstance();
158
158
  const { trigger, data, error, reset, isMutating } = useSWRMutation(
159
159
  fullUrl,
160
160
  // method === "POST" ? fetcher : deleteFetcher,
@@ -172,7 +172,7 @@ var useMutation = (url, method = "POST", options) => {
172
172
  url: newUrl,
173
173
  data: data2
174
174
  };
175
- const signer = account10.signer;
175
+ const signer = account9.signer;
176
176
  const signature = await signer.sign(payload, getTimestamp());
177
177
  return trigger(
178
178
  {
@@ -181,7 +181,7 @@ var useMutation = (url, method = "POST", options) => {
181
181
  method,
182
182
  signature: {
183
183
  ...signature,
184
- "orderly-account-id": account10.accountId
184
+ "orderly-account-id": account9.accountId
185
185
  }
186
186
  },
187
187
  options2
@@ -195,9 +195,9 @@ var signatureMiddleware = (useSWRNext) => {
195
195
  try {
196
196
  const extendedFetcher = async (args) => {
197
197
  const url = Array.isArray(args) ? args[0] : args;
198
- const account10 = SimpleDI.get("account");
198
+ const account9 = SimpleDI.get("account");
199
199
  const fullUrl = `${apiBaseUrl}${url}`;
200
- const signer = account10.signer;
200
+ const signer = account9.signer;
201
201
  const payload = {
202
202
  method: "GET",
203
203
  url
@@ -206,7 +206,7 @@ var signatureMiddleware = (useSWRNext) => {
206
206
  return fetcher4(fullUrl, {
207
207
  headers: {
208
208
  ...signature,
209
- "orderly-account-id": account10.accountId
209
+ "orderly-account-id": account9.accountId
210
210
  }
211
211
  });
212
212
  };
@@ -279,25 +279,25 @@ var useWS = () => {
279
279
  const { configStore } = useContext(OrderlyContext);
280
280
  const ws = useConstant(() => {
281
281
  let websocketClient = SimpleDI.get(WS_NAME);
282
- const account10 = SimpleDI.get(Account.instanceName);
282
+ const account9 = SimpleDI.get(Account.instanceName);
283
283
  if (!websocketClient) {
284
284
  websocketClient = new WS({
285
285
  networkId: configStore.get("networkId"),
286
286
  publicUrl: configStore.get("publicWsUrl"),
287
287
  privateUrl: configStore.get("privateWsUrl"),
288
288
  onSigntureRequest: async () => {
289
- const signer = account10.signer;
289
+ const signer = account9.signer;
290
290
  const timestamp = getTimestamp();
291
291
  const result = await signer.signText(timestamp.toString());
292
292
  return { ...result, timestamp };
293
293
  }
294
294
  });
295
- if ((account10.stateValue.status === AccountStatusEnum.EnableTrading || account10.stateValue.status === AccountStatusEnum.EnableTradingWithoutConnected) && account10.accountId) {
296
- websocketClient.openPrivate(account10.accountId);
295
+ if ((account9.stateValue.status === AccountStatusEnum.EnableTrading || account9.stateValue.status === AccountStatusEnum.EnableTradingWithoutConnected) && account9.accountId) {
296
+ websocketClient.openPrivate(account9.accountId);
297
297
  }
298
- account10.on("change:status", (nextState) => {
299
- if ((nextState.status === AccountStatusEnum.EnableTrading || nextState.status === AccountStatusEnum.EnableTradingWithoutConnected) && account10.accountId) {
300
- websocketClient.openPrivate(account10.accountId);
298
+ account9.on("change:status", (nextState) => {
299
+ if ((nextState.status === AccountStatusEnum.EnableTrading || nextState.status === AccountStatusEnum.EnableTradingWithoutConnected) && account9.accountId) {
300
+ websocketClient.openPrivate(account9.accountId);
301
301
  } else {
302
302
  websocketClient.closePrivate(3887, "switch account");
303
303
  }
@@ -324,63 +324,63 @@ var useAccount = () => {
324
324
  "keyStore is not defined, please use OrderlyProvider and provide keyStore"
325
325
  );
326
326
  }
327
- const account10 = useAccountInstance();
328
- const [state, setState] = useState(account10.stateValue);
327
+ const account9 = useAccountInstance();
328
+ const [state, setState] = useState(account9.stateValue);
329
329
  const { track: track2 } = useTrack();
330
330
  const statusChangeHandler = (nextState) => {
331
331
  setState(() => nextState);
332
332
  };
333
333
  useEffect(() => {
334
- account10.on("change:status", statusChangeHandler);
334
+ account9.on("change:status", statusChangeHandler);
335
335
  return () => {
336
- account10.off("change:status", statusChangeHandler);
336
+ account9.off("change:status", statusChangeHandler);
337
337
  };
338
- }, [account10]);
338
+ }, [account9]);
339
339
  const createOrderlyKey = useCallback(
340
340
  async (remember) => {
341
341
  track2(TrackerEventName.signinSuccess, {
342
- network: account10.chainId,
342
+ network: account9.chainId,
343
343
  wallet: state.connectWallet?.name
344
344
  });
345
- return account10.createOrderlyKey(remember ? 365 : 30).then((res) => {
346
- return account10.restoreSubAccount().then((_) => {
345
+ return account9.createOrderlyKey(remember ? 365 : 30).then((res) => {
346
+ return account9.restoreSubAccount().then((_) => {
347
347
  return res;
348
348
  });
349
349
  });
350
350
  },
351
- [account10, state]
351
+ [account9, state]
352
352
  );
353
353
  const ws = useWS();
354
354
  const switchAccount = useCallback(
355
355
  async (accountId) => {
356
356
  ws.closePrivate(3887, "switch account");
357
- return account10.switchAccount(accountId);
357
+ return account9.switchAccount(accountId);
358
358
  },
359
- [account10]
359
+ [account9]
360
360
  );
361
361
  const createAccount = useCallback(async () => {
362
- return account10.createAccount();
363
- }, [account10]);
362
+ return account9.createAccount();
363
+ }, [account9]);
364
364
  const createSubAccount = useCallback(
365
365
  async (description) => {
366
- return account10.createSubAccount(description);
366
+ return account9.createSubAccount(description);
367
367
  },
368
- [account10]
368
+ [account9]
369
369
  );
370
370
  const updateSubAccount = useCallback(
371
371
  async (value) => {
372
- return account10.updateSubAccount(value);
372
+ return account9.updateSubAccount(value);
373
373
  },
374
- [account10]
374
+ [account9]
375
375
  );
376
376
  const refreshSubAccountBalances = useCallback(() => {
377
- return account10.refreshSubAccountBalances();
378
- }, [account10]);
377
+ return account9.refreshSubAccountBalances();
378
+ }, [account9]);
379
379
  const isSubAccount = useMemo(() => {
380
380
  return state.accountId !== state.mainAccountId;
381
381
  }, [state]);
382
382
  return {
383
- account: account10,
383
+ account: account9,
384
384
  state,
385
385
  isSubAccount,
386
386
  isMainAccount: !isSubAccount,
@@ -866,7 +866,7 @@ var useGetReferralCode = (accountId) => {
866
866
  };
867
867
  function useSubAccountQuery(query, options) {
868
868
  const { formatter, accountId, ...swrOptions } = options || {};
869
- const { state, account: account10 } = useAccount();
869
+ const { state, account: account9 } = useAccount();
870
870
  const middleware = Array.isArray(options?.use) ? options?.use ?? [] : [];
871
871
  return useSWR__default(
872
872
  () => accountId && (state.status >= AccountStatusEnum.EnableTrading || state.status === AccountStatusEnum.EnableTradingWithoutConnected) ? [query, accountId] : null,
@@ -875,13 +875,13 @@ function useSubAccountQuery(query, options) {
875
875
  },
876
876
  {
877
877
  ...swrOptions,
878
- use: [...middleware, signatureMiddleware2(account10, accountId)],
878
+ use: [...middleware, signatureMiddleware2(account9, accountId)],
879
879
  onError: () => {
880
880
  }
881
881
  }
882
882
  );
883
883
  }
884
- function signatureMiddleware2(account10, accountId) {
884
+ function signatureMiddleware2(account9, accountId) {
885
885
  const apiBaseUrl = useConfig("apiBaseUrl");
886
886
  return (useSWRNext) => {
887
887
  return (key, fetcher4, config) => {
@@ -889,7 +889,7 @@ function signatureMiddleware2(account10, accountId) {
889
889
  const extendedFetcher = async (args) => {
890
890
  const url = Array.isArray(args) ? args[0] : args;
891
891
  const fullUrl = `${apiBaseUrl}${url}`;
892
- const signer = account10.signer;
892
+ const signer = account9.signer;
893
893
  const payload = {
894
894
  method: "GET",
895
895
  url
@@ -6122,7 +6122,7 @@ var useMaxWithdrawal = (token) => {
6122
6122
  // src/orderly/useWithdraw.ts
6123
6123
  var useWithdraw = (options) => {
6124
6124
  const { srcChainId, token = "", decimals } = options;
6125
- const { account: account10, state } = useAccount();
6125
+ const { account: account9, state } = useAccount();
6126
6126
  const { unsettledPnL, availableBalance, freeCollateral } = useCollateral();
6127
6127
  const networkId = useConfig("networkId");
6128
6128
  const [_, { findByChainId }] = useChains(void 0);
@@ -6163,7 +6163,7 @@ var useWithdraw = (options) => {
6163
6163
  }, [targetChain]);
6164
6164
  const withdraw = useCallback(
6165
6165
  (inputs) => {
6166
- return account10.assetsManager.withdraw({ ...inputs, decimals: decimals ?? 6 }).then((res) => {
6166
+ return account9.assetsManager.withdraw({ ...inputs, decimals: decimals ?? 6 }).then((res) => {
6167
6167
  if (res.success) {
6168
6168
  track2(TrackerEventName.withdrawSuccess, {
6169
6169
  wallet: state?.connectWallet?.name,
@@ -6183,7 +6183,7 @@ var useWithdraw = (options) => {
6183
6183
  });
6184
6184
  },
6185
6185
  [
6186
- account10.assetsManager,
6186
+ account9.assetsManager,
6187
6187
  decimals,
6188
6188
  state?.connectWallet?.name,
6189
6189
  targetChain?.network_infos.name
@@ -6210,7 +6210,7 @@ var useDeposit = (options) => {
6210
6210
  const [balance, setBalance] = useState("0");
6211
6211
  const [allowance, setAllowance] = useState("0");
6212
6212
  const balanceRef = useRef("");
6213
- const { account: account10, state } = useAccount();
6213
+ const { account: account9, state } = useAccount();
6214
6214
  const { track: track2 } = useTrack();
6215
6215
  const prevAddress = useRef();
6216
6216
  const getBalanceListener = useRef();
@@ -6249,18 +6249,18 @@ var useDeposit = (options) => {
6249
6249
  let balance2;
6250
6250
  try {
6251
6251
  if (address && isNativeTokenChecker(address)) {
6252
- balance2 = await account10.assetsManager.getNativeBalance({
6252
+ balance2 = await account9.assetsManager.getNativeBalance({
6253
6253
  decimals
6254
6254
  });
6255
6255
  } else {
6256
- balance2 = await account10.assetsManager.getBalance(address, {
6256
+ balance2 = await account9.assetsManager.getBalance(address, {
6257
6257
  decimals
6258
6258
  });
6259
6259
  }
6260
6260
  } catch (err) {
6261
6261
  if (ignoreBalanceError({
6262
6262
  token: options.srcToken,
6263
- chainNamespace: account10.walletAdapter?.chainNamespace,
6263
+ chainNamespace: account9.walletAdapter?.chainNamespace,
6264
6264
  err
6265
6265
  })) {
6266
6266
  return "0";
@@ -6269,7 +6269,7 @@ var useDeposit = (options) => {
6269
6269
  }
6270
6270
  return balance2;
6271
6271
  },
6272
- [options.srcToken, account10]
6272
+ [options.srcToken, account9]
6273
6273
  );
6274
6274
  const fetchBalances = useCallback(async (tokens) => {
6275
6275
  const tasks = [];
@@ -6278,7 +6278,7 @@ var useDeposit = (options) => {
6278
6278
  continue;
6279
6279
  }
6280
6280
  tasks.push(
6281
- account10.assetsManager.getBalance(token.address, {
6281
+ account9.assetsManager.getBalance(token.address, {
6282
6282
  decimals: token?.decimals
6283
6283
  })
6284
6284
  );
@@ -6296,7 +6296,7 @@ var useDeposit = (options) => {
6296
6296
  if (isNativeTokenChecker(address))
6297
6297
  return;
6298
6298
  prevAddress.current = key;
6299
- const allowance2 = await account10.assetsManager.getAllowance({
6299
+ const allowance2 = await account9.assetsManager.getAllowance({
6300
6300
  address,
6301
6301
  vaultAddress: vaultAddress2,
6302
6302
  decimals
@@ -6311,7 +6311,7 @@ var useDeposit = (options) => {
6311
6311
  if (!address || isNativeTokenChecker(address))
6312
6312
  return;
6313
6313
  prevAddress.current = address;
6314
- const allowance2 = await account10.assetsManager.getAllowance({
6314
+ const allowance2 = await account9.assetsManager.getAllowance({
6315
6315
  address,
6316
6316
  decimals,
6317
6317
  vaultAddress
@@ -6356,9 +6356,9 @@ var useDeposit = (options) => {
6356
6356
  return;
6357
6357
  setBalanceRevalidating(true);
6358
6358
  queryBalance(options.address, options.decimals);
6359
- if (account10.walletAdapter?.chainNamespace === ChainNamespace.solana) {
6359
+ if (account9.walletAdapter?.chainNamespace === ChainNamespace.solana) {
6360
6360
  setAllowance(
6361
- account10.walletAdapter.formatUnits(MaxUint256, options.decimals)
6361
+ account9.walletAdapter.formatUnits(MaxUint256, options.decimals)
6362
6362
  );
6363
6363
  return;
6364
6364
  }
@@ -6378,14 +6378,14 @@ var useDeposit = (options) => {
6378
6378
  state.status,
6379
6379
  options.address,
6380
6380
  options.decimals,
6381
- account10.address,
6381
+ account9.address,
6382
6382
  vaultAddress
6383
6383
  ]);
6384
6384
  const updateAllowanceWhenTxSuccess = useCallback(
6385
6385
  (txHash) => {
6386
- return account10.walletAdapter?.pollTransactionReceiptWithBackoff(txHash).then((receipt) => {
6386
+ return account9.walletAdapter?.pollTransactionReceiptWithBackoff(txHash).then((receipt) => {
6387
6387
  if (receipt.status === 1) {
6388
- account10.assetsManager.getAllowance({
6388
+ account9.assetsManager.getAllowance({
6389
6389
  address: options.address,
6390
6390
  decimals: options.decimals,
6391
6391
  vaultAddress
@@ -6395,7 +6395,7 @@ var useDeposit = (options) => {
6395
6395
  }
6396
6396
  });
6397
6397
  },
6398
- [account10, options.address, options.decimals, vaultAddress]
6398
+ [account9, options.address, options.decimals, vaultAddress]
6399
6399
  );
6400
6400
  const enquireAllowance = useCallback(async () => {
6401
6401
  if (isNativeToken) {
@@ -6404,7 +6404,7 @@ var useDeposit = (options) => {
6404
6404
  if (!options.address) {
6405
6405
  throw new Error("address is required");
6406
6406
  }
6407
- const _allowance = await account10.assetsManager.getAllowance({
6407
+ const _allowance = await account9.assetsManager.getAllowance({
6408
6408
  address: options.address,
6409
6409
  vaultAddress,
6410
6410
  decimals: options.decimals
@@ -6415,7 +6415,7 @@ var useDeposit = (options) => {
6415
6415
  }
6416
6416
  return _allowance;
6417
6417
  }, [
6418
- account10,
6418
+ account9,
6419
6419
  options.address,
6420
6420
  options.decimals,
6421
6421
  vaultAddress,
@@ -6436,17 +6436,17 @@ var useDeposit = (options) => {
6436
6436
  );
6437
6437
  const resetApprove = useCallback(
6438
6438
  async (tokenAddress, decimal, vaultAddress2) => {
6439
- const result = await account10.assetsManager.approve({
6439
+ const result = await account9.assetsManager.approve({
6440
6440
  address: tokenAddress,
6441
6441
  amount: "0",
6442
6442
  vaultAddress: vaultAddress2,
6443
6443
  decimals: decimal
6444
6444
  });
6445
- const txResult = await account10.walletAdapter?.pollTransactionReceiptWithBackoff(
6445
+ const txResult = await account9.walletAdapter?.pollTransactionReceiptWithBackoff(
6446
6446
  result.hash
6447
6447
  );
6448
6448
  if (txResult && txResult.status === 1) {
6449
- account10.assetsManager.getAllowance({
6449
+ account9.assetsManager.getAllowance({
6450
6450
  address: tokenAddress,
6451
6451
  decimals: decimal,
6452
6452
  vaultAddress: vaultAddress2
@@ -6473,7 +6473,7 @@ var useDeposit = (options) => {
6473
6473
  );
6474
6474
  }
6475
6475
  }
6476
- return account10.assetsManager.approve({
6476
+ return account9.assetsManager.approve({
6477
6477
  address: options.address,
6478
6478
  amount,
6479
6479
  vaultAddress,
@@ -6484,7 +6484,7 @@ var useDeposit = (options) => {
6484
6484
  });
6485
6485
  },
6486
6486
  [
6487
- account10,
6487
+ account9,
6488
6488
  options.srcChainId,
6489
6489
  options.srcToken,
6490
6490
  allowance,
@@ -6506,7 +6506,7 @@ var useDeposit = (options) => {
6506
6506
  address: options.address,
6507
6507
  vaultAddress
6508
6508
  };
6509
- const depositPromise = isNativeToken ? account10.assetsManager.depositNativeToken(inputs) : account10.assetsManager.deposit(inputs);
6509
+ const depositPromise = isNativeToken ? account9.assetsManager.depositNativeToken(inputs) : account9.assetsManager.deposit(inputs);
6510
6510
  return depositPromise.then((result) => {
6511
6511
  updateAllowanceWhenTxSuccess(result.hash);
6512
6512
  setBalance((value) => new Decimal(value).sub(quantity).toString());
@@ -6526,7 +6526,7 @@ var useDeposit = (options) => {
6526
6526
  });
6527
6527
  }, [
6528
6528
  state,
6529
- account10,
6529
+ account9,
6530
6530
  quantity,
6531
6531
  depositFee,
6532
6532
  targetChain,
@@ -6541,7 +6541,7 @@ var useDeposit = (options) => {
6541
6541
  if (getBalanceListener.current) {
6542
6542
  clearTimeout(getBalanceListener.current);
6543
6543
  }
6544
- const time = timeout ?? (account10.walletAdapter?.chainNamespace === ChainNamespace.solana ? 1e4 : 3e3);
6544
+ const time = timeout ?? (account9.walletAdapter?.chainNamespace === ChainNamespace.solana ? 1e4 : 3e3);
6545
6545
  if (balanceRef.current === "") {
6546
6546
  setBalanceRevalidating(true);
6547
6547
  }
@@ -6565,7 +6565,7 @@ var useDeposit = (options) => {
6565
6565
  };
6566
6566
  const getDepositFee = useCallback(
6567
6567
  async (quantity2) => {
6568
- return account10.assetsManager.getDepositFee({
6568
+ return account9.assetsManager.getDepositFee({
6569
6569
  amount: quantity2,
6570
6570
  chain: targetChain?.network_infos,
6571
6571
  decimals: options.decimals,
@@ -6573,7 +6573,7 @@ var useDeposit = (options) => {
6573
6573
  address: options.address
6574
6574
  });
6575
6575
  },
6576
- [account10, targetChain, options.decimals, options.srcToken, options.address]
6576
+ [account9, targetChain, options.decimals, options.srcToken, options.address]
6577
6577
  );
6578
6578
  const enquiryDepositFee = useCallback(() => {
6579
6579
  if (isNaN(Number(quantity)) || !quantity || Number(quantity) === 0) {
@@ -6636,10 +6636,10 @@ function ignoreBalanceError(options) {
6636
6636
  // src/orderly/useConvert.ts
6637
6637
  var useConvert = (options) => {
6638
6638
  const { token = "" } = options;
6639
- const { account: account10 } = useAccount();
6639
+ const { account: account9 } = useAccount();
6640
6640
  const maxAmount = useMaxWithdrawal(token);
6641
6641
  const convert = async (inputs) => {
6642
- return account10.assetsManager.convert({
6642
+ return account9.assetsManager.convert({
6643
6643
  ...inputs,
6644
6644
  converted_asset: token
6645
6645
  });
@@ -6669,7 +6669,7 @@ var useSubAccountMutation = (url, method = "POST", options) => {
6669
6669
  if (!url.startsWith("http")) {
6670
6670
  fullUrl = `${apiBaseUrl}${url}`;
6671
6671
  }
6672
- const account10 = useAccountInstance();
6672
+ const account9 = useAccountInstance();
6673
6673
  const { trigger, reset, data, error, isMutating } = useSWRMutation(
6674
6674
  fullUrl,
6675
6675
  // method === "POST" ? fetcher : deleteFetcher,
@@ -6688,7 +6688,7 @@ var useSubAccountMutation = (url, method = "POST", options) => {
6688
6688
  url: newUrl,
6689
6689
  data: data2
6690
6690
  };
6691
- const signer = account10.signer;
6691
+ const signer = account9.signer;
6692
6692
  const signature = await signer.sign(payload, getTimestamp());
6693
6693
  return trigger(
6694
6694
  {
@@ -6697,7 +6697,7 @@ var useSubAccountMutation = (url, method = "POST", options) => {
6697
6697
  method,
6698
6698
  signature: {
6699
6699
  ...signature,
6700
- "orderly-account-id": accountId || _accountId || account10.accountId
6700
+ "orderly-account-id": accountId || _accountId || account9.accountId
6701
6701
  }
6702
6702
  },
6703
6703
  restOptions2
@@ -6744,11 +6744,11 @@ var useTransfer = (options) => {
6744
6744
  };
6745
6745
  var useInternalTransfer = () => {
6746
6746
  const [submitting, setSubmitting] = useState(false);
6747
- const { account: account10 } = useAccount();
6747
+ const { account: account9 } = useAccount();
6748
6748
  const transfer = useCallback(
6749
6749
  async (inputs) => {
6750
6750
  setSubmitting(true);
6751
- return account10.assetsManager.internalTransfer(inputs).then((res) => {
6751
+ return account9.assetsManager.internalTransfer(inputs).then((res) => {
6752
6752
  if (res.success) {
6753
6753
  return res;
6754
6754
  }
@@ -6759,7 +6759,7 @@ var useInternalTransfer = () => {
6759
6759
  setSubmitting(false);
6760
6760
  });
6761
6761
  },
6762
- [account10]
6762
+ [account9]
6763
6763
  );
6764
6764
  return {
6765
6765
  submitting,
@@ -9018,7 +9018,7 @@ function calcByPrice(positions3, markPrice, indexPrice) {
9018
9018
  var useSubAccountWS = (options) => {
9019
9019
  const { accountId } = options;
9020
9020
  const { configStore } = useContext(OrderlyContext);
9021
- const { state, account: account10 } = useAccount();
9021
+ const { state, account: account9 } = useAccount();
9022
9022
  const websocketClient = useRef(
9023
9023
  new WS({
9024
9024
  networkId: configStore.get("networkId"),
@@ -9026,7 +9026,7 @@ var useSubAccountWS = (options) => {
9026
9026
  // publicUrl: configStore.get("publicWsUrl"),
9027
9027
  privateUrl: configStore.get("privateWsUrl"),
9028
9028
  onSigntureRequest: async () => {
9029
- const signer = account10.signer;
9029
+ const signer = account9.signer;
9030
9030
  const timestamp = getTimestamp();
9031
9031
  const result = await signer.signText(timestamp.toString());
9032
9032
  return { ...result, timestamp };
@@ -9610,82 +9610,6 @@ var useSymbolLeverage = (symbol) => {
9610
9610
  isLoading: isMutating
9611
9611
  };
9612
9612
  };
9613
- var useEffectiveLeverage = (inputs) => {
9614
- const {
9615
- symbol,
9616
- positionQty = 0,
9617
- positionPrice,
9618
- orderQty = 0,
9619
- orderPrice,
9620
- selectedLeverage: inputSelectedLeverage
9621
- } = inputs;
9622
- const accountInfo = useAccountInfo2();
9623
- const symbolsInfo = useSymbolsInfo();
9624
- const maxLeverage = useMaxLeverage(symbol);
9625
- const markPriceData = useMarkPrice(symbol);
9626
- const markPrice = markPriceData?.data ?? 0;
9627
- return useMemo(() => {
9628
- const effectivePositionPrice = positionPrice ?? markPrice;
9629
- const effectiveOrderPrice = orderPrice ?? markPrice;
9630
- const positionNotional = Math.abs(
9631
- new Decimal(positionQty).mul(effectivePositionPrice).toNumber()
9632
- );
9633
- const orderNotional = Math.abs(
9634
- new Decimal(orderQty).mul(effectiveOrderPrice).toNumber()
9635
- );
9636
- const symbolInfo = symbolsInfo[symbol];
9637
- const baseIMR = symbolInfo("base_imr");
9638
- const selectedLeverage = inputSelectedLeverage ?? maxLeverage;
9639
- if (baseIMR === void 0 || baseIMR === null) {
9640
- return {
9641
- selectedLeverage,
9642
- effectiveLeverage: maxLeverage,
9643
- displayLeverage: Math.min(selectedLeverage, maxLeverage),
9644
- imr: 1 / maxLeverage,
9645
- isConstrained: false,
9646
- constraintMessage: void 0
9647
- };
9648
- }
9649
- const imrFactor = accountInfo?.imr_factor?.[symbol] ?? 0;
9650
- const calculatedIMR = account.IMR({
9651
- maxLeverage,
9652
- baseIMR,
9653
- IMR_Factor: imrFactor,
9654
- positionNotional,
9655
- ordersNotional: orderNotional,
9656
- IMR_factor_power: 4 / 5
9657
- });
9658
- const effectiveLeverage = 1 / calculatedIMR;
9659
- const displayLeverage = Math.min(selectedLeverage, effectiveLeverage);
9660
- const isConstrained = effectiveLeverage < selectedLeverage;
9661
- let constraintMessage;
9662
- if (isConstrained) {
9663
- const totalNotional = new Decimal(positionNotional).add(orderNotional);
9664
- constraintMessage = `For this position size ($${totalNotional.toFixed(
9665
- 2
9666
- )}), the maximum effective leverage is ${Math.floor(effectiveLeverage)}x`;
9667
- }
9668
- return {
9669
- selectedLeverage,
9670
- effectiveLeverage,
9671
- displayLeverage,
9672
- imr: calculatedIMR,
9673
- isConstrained,
9674
- constraintMessage
9675
- };
9676
- }, [
9677
- symbol,
9678
- symbolsInfo,
9679
- accountInfo,
9680
- positionQty,
9681
- positionPrice,
9682
- orderQty,
9683
- orderPrice,
9684
- markPrice,
9685
- inputSelectedLeverage,
9686
- maxLeverage
9687
- ]);
9688
- };
9689
9613
  var useAssetsHistory = (options, config) => {
9690
9614
  const ee = useEventEmitter();
9691
9615
  const getKey = () => {
@@ -10032,7 +9956,7 @@ var useStorageLedgerAddress = () => {
10032
9956
  var usePrivateDataObserver = (options) => {
10033
9957
  const ws = useWS();
10034
9958
  const ee = useEventEmitter();
10035
- const { state, account: account10 } = useAccount();
9959
+ const { state, account: account9 } = useAccount();
10036
9960
  const { setAccountInfo, restoreHolding, cleanAll } = useAppStore(
10037
9961
  (state2) => state2.actions
10038
9962
  );
@@ -10065,9 +9989,9 @@ var usePrivateDataObserver = (options) => {
10065
9989
  positionsActions.clearAll();
10066
9990
  }
10067
9991
  };
10068
- account10.on(EVENT_NAMES.statusChanged, handler);
9992
+ account9.on(EVENT_NAMES.statusChanged, handler);
10069
9993
  return () => {
10070
- account10.off(EVENT_NAMES.statusChanged, handler);
9994
+ account9.off(EVENT_NAMES.statusChanged, handler);
10071
9995
  };
10072
9996
  }, []);
10073
9997
  useEffect(() => {
@@ -10088,7 +10012,7 @@ var usePrivateDataObserver = (options) => {
10088
10012
  }
10089
10013
  );
10090
10014
  useEffect(() => {
10091
- if (!account10.accountId)
10015
+ if (!account9.accountId)
10092
10016
  return;
10093
10017
  const unsubscribe = ws.privateSubscribe(
10094
10018
  {
@@ -10107,7 +10031,7 @@ var usePrivateDataObserver = (options) => {
10107
10031
  }
10108
10032
  );
10109
10033
  return () => unsubscribe?.();
10110
- }, [account10.accountId]);
10034
+ }, [account9.accountId]);
10111
10035
  const isHoldingInit = useRef(false);
10112
10036
  useEffect(() => {
10113
10037
  isHoldingInit.current = false;
@@ -10435,7 +10359,7 @@ var DataCenterProvider = ({
10435
10359
  return /* @__PURE__ */ jsx(DataCenterContext.Provider, { value: memoizedValue, children });
10436
10360
  };
10437
10361
  var OrderlyConfigProvider = (props) => {
10438
- const [account10, setAccount] = React2.useState(null);
10362
+ const [account9, setAccount] = React2.useState(null);
10439
10363
  const {
10440
10364
  configStore,
10441
10365
  keyStore,
@@ -10492,9 +10416,9 @@ var OrderlyConfigProvider = (props) => {
10492
10416
  return orderbookDefaultSymbolDepths || DEFAULT_SYMBOL_DEPTHS;
10493
10417
  }, [orderbookDefaultSymbolDepths]);
10494
10418
  useLayoutEffect(() => {
10495
- let account11 = SimpleDI.get(Account.instanceName);
10496
- if (!account11) {
10497
- account11 = new Account(
10419
+ let account10 = SimpleDI.get(Account.instanceName);
10420
+ if (!account10) {
10421
+ account10 = new Account(
10498
10422
  innerConfigStore,
10499
10423
  innerKeyStore,
10500
10424
  // innerGetWalletAdapter,
@@ -10503,9 +10427,9 @@ var OrderlyConfigProvider = (props) => {
10503
10427
  contracts
10504
10428
  }
10505
10429
  );
10506
- SimpleDI.registerByName(Account.instanceName, account11);
10430
+ SimpleDI.registerByName(Account.instanceName, account10);
10507
10431
  }
10508
- setAccount(account11);
10432
+ setAccount(account10);
10509
10433
  }, []);
10510
10434
  const filteredChains = useMemo(() => {
10511
10435
  if (typeof chainFilter === "function") {
@@ -10546,7 +10470,7 @@ var OrderlyConfigProvider = (props) => {
10546
10470
  amplitudeConfig,
10547
10471
  orderMetadata
10548
10472
  ]);
10549
- if (!account10) {
10473
+ if (!account9) {
10550
10474
  return null;
10551
10475
  }
10552
10476
  return /* @__PURE__ */ jsx(OrderlyProvider, { value: memoizedValue, children: /* @__PURE__ */ jsx(StatusProvider, { children: /* @__PURE__ */ jsx(DataCenterProvider, { children }) }) });
@@ -11726,9 +11650,9 @@ var useAllBrokers = () => {
11726
11650
  };
11727
11651
  var useCurEpochEstimate = (type) => {
11728
11652
  const [data, setData] = useState(void 0);
11729
- const { account: account10 } = useAccount();
11653
+ const { account: account9 } = useAccount();
11730
11654
  const brokers = useAllBrokers();
11731
- const address = account10.address;
11655
+ const address = account9.address;
11732
11656
  const path2 = type === "normal" /* normal */ ? `/v1/public/trading_rewards/current_epoch_estimate?address=${address}` : `/v1/public/market_making_rewards/current_epoch_estimate?address=${address}`;
11733
11657
  const { data: estimateData } = useQuery(address !== void 0 ? path2 : "", {
11734
11658
  formatter: (res) => {
@@ -16688,14 +16612,14 @@ var DistributionId = /* @__PURE__ */ ((DistributionId2) => {
16688
16612
  })(DistributionId || {});
16689
16613
  var useGetClaimed = (id) => {
16690
16614
  const [data, setData] = useState(0);
16691
- const { account: account10 } = useAccount();
16692
- const address = account10.address;
16615
+ const { account: account9 } = useAccount();
16616
+ const address = account9.address;
16693
16617
  const env = useGetEnv();
16694
16618
  const refresh = useCallback(() => {
16695
16619
  const params = getContractByEnv(env);
16696
16620
  if (typeof address === "undefined")
16697
16621
  return;
16698
- account10.walletAdapter?.callOnChain(
16622
+ account9.walletAdapter?.callOnChain(
16699
16623
  // @ts-ignore
16700
16624
  { public_rpc_url: params.orderlyChainRpcUrl },
16701
16625
  params.orderlyContract,
@@ -16720,8 +16644,8 @@ var useGetClaimed = (id) => {
16720
16644
 
16721
16645
  // src/trading-rewards/useWalletRewardsHistory.ts
16722
16646
  var useWalletRewardsHistory = (type) => {
16723
- const { account: account10 } = useAccount();
16724
- const address = account10.address;
16647
+ const { account: account9 } = useAccount();
16648
+ const address = account9.address;
16725
16649
  const path2 = type === "normal" /* normal */ ? `/v1/public/trading_rewards/wallet_rewards_history?address=${address}` : `/v1/public/market_making_rewards/group_rewards_history?address=${address}`;
16726
16650
  const {
16727
16651
  data,
@@ -16769,7 +16693,7 @@ function useTradingRewardsStatus(isMMRewards) {
16769
16693
  };
16770
16694
  }
16771
16695
  var useApiKeyManager = (queryParams) => {
16772
- const { account: account10, state, isSubAccount } = useAccount();
16696
+ const { account: account9, state, isSubAccount } = useAccount();
16773
16697
  const { keyInfo } = queryParams || {};
16774
16698
  const keyInfoPrams = getQueryParamsFromObject(keyInfo);
16775
16699
  const { data, mutate: mutate5, error, isLoading } = usePrivateQuery(
@@ -16806,13 +16730,13 @@ var useApiKeyManager = (queryParams) => {
16806
16730
  }, []);
16807
16731
  const generateOrderlyKey = (scope) => {
16808
16732
  if (isSubAccount) {
16809
- return account10?.createSubAccountApiKey(365, {
16733
+ return account9?.createSubAccountApiKey(365, {
16810
16734
  tag: "manualCreated",
16811
16735
  scope,
16812
16736
  subAccountId: state.accountId
16813
16737
  });
16814
16738
  }
16815
- return account10?.createApiKey(365, {
16739
+ return account9?.createApiKey(365, {
16816
16740
  tag: "manualCreated",
16817
16741
  scope
16818
16742
  });
@@ -17871,6 +17795,6 @@ var usePositionClose = (options) => {
17871
17795
  };
17872
17796
  };
17873
17797
 
17874
- export { DefaultLayoutConfig, DistributionId, ENVType2 as ENVType, EpochStatus, ExtendedConfigStore, MaintenanceStatus, MarketsStorageKey, MarketsType, ORDERLY_ORDERBOOK_DEPTH_KEY, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, StatusProvider, TWType, WalletConnectorContext, WsNetworkStatus, checkNotional, cleanStringStyle, fetcher, findPositionTPSLFromOrders, findTPSLFromOrder, findTPSLOrderPriceFromOrder, getMinNotional, getPriceKey, noCacheConfig, parseJSON, useAccount, useAccountInfo, useAccountInstance, useAccountRewardsHistory, useAllBrokers, useApiKeyManager, useAssetsHistory, useAudioPlayer, useBalanceSubscription, useBalanceTopic, useBoolean, useChain, useChainInfo, useChains, useCheckReferralCode, useCollateral, useCommission, useComputedLTV, useConfig, useConvert, useCurEpochEstimate, useDaily, useDeposit, useDistribution, useDistributionHistory, useEffectiveLeverage, useEpochInfo, useEventEmitter, useFeeState, useFundingDetails, useFundingFeeHistory, useFundingRate, useFundingRateHistory, useFundingRates, useFundingRatesStore, useGetClaimed, useGetEnv, useGetReferralCode, useHoldingStream, useIndexPrice, useIndexPricesStream, useInfiniteQuery, useInternalTransfer, useKeyStore, useLazyQuery, useLeverage, useLeverageBySymbol, useLocalStorage, useMaintenanceStatus, useMarginRatio, useMarkPrice, useMarkPriceBySymbol, useMarkPricesStream, useMarket, useMarketList, useMarketMap, useMarketTradeStream, useMarkets, useMarketsStore, useMarketsStream, useMaxLeverage, useMaxQty, useMaxWithdrawal, useMediaQuery, useMemoizedFn, useMutation, useNetworkInfo, useOdosQuote, useOrderEntity, useOrderEntry2 as useOrderEntry, useOrderEntry as useOrderEntry_deprecated, useOrderStore2 as useOrderStore, useOrderStream, useOrderbookStream, useOrderlyContext, usePortfolio, usePositionActions, usePositionClose, usePositionStore, usePositionStream, usePoster, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useRefereeHistory, useRefereeInfo, useRefereeRebateSummary, useReferralInfo, useReferralRebateSummary, useRestrictedInfo, useSessionStorage, useSettleSubscription, useSimpleDI, useStatisticsDaily, useStorageChain, useStorageLedgerAddress, useSubAccountDataObserver, useSubAccountMaxWithdrawal, useSubAccountMutation, useSubAccountQuery, useSubAccountWS, useSymbolInfo, useSymbolLeverage, useSymbolPriceRange, useSymbolsInfo, useSymbolsInfoStore, useTPSLOrder, useTickerStream, useTokenInfo, useTokensInfo, useTrack, useTrackingInstance, useTradingRewardsStatus, useTransfer, useTransferHistory, useUpdatedRef, useVaultsHistory, useWS, useWalletConnector, useWalletRewardsHistory, useWalletSubscription, useWalletTopic, useWithdraw, useWsStatus, utils_exports as utils, version_default as version };
17798
+ export { DefaultLayoutConfig, DistributionId, ENVType2 as ENVType, EpochStatus, ExtendedConfigStore, MaintenanceStatus, MarketsStorageKey, MarketsType, ORDERLY_ORDERBOOK_DEPTH_KEY, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, StatusProvider, TWType, WalletConnectorContext, WsNetworkStatus, checkNotional, cleanStringStyle, fetcher, findPositionTPSLFromOrders, findTPSLFromOrder, findTPSLOrderPriceFromOrder, getMinNotional, getPriceKey, noCacheConfig, parseJSON, useAccount, useAccountInfo, useAccountInstance, useAccountRewardsHistory, useAllBrokers, useApiKeyManager, useAssetsHistory, useAudioPlayer, useBalanceSubscription, useBalanceTopic, useBoolean, useChain, useChainInfo, useChains, useCheckReferralCode, useCollateral, useCommission, useComputedLTV, useConfig, useConvert, useCurEpochEstimate, useDaily, useDeposit, useDistribution, useDistributionHistory, useEpochInfo, useEventEmitter, useFeeState, useFundingDetails, useFundingFeeHistory, useFundingRate, useFundingRateHistory, useFundingRates, useFundingRatesStore, useGetClaimed, useGetEnv, useGetReferralCode, useHoldingStream, useIndexPrice, useIndexPricesStream, useInfiniteQuery, useInternalTransfer, useKeyStore, useLazyQuery, useLeverage, useLeverageBySymbol, useLocalStorage, useMaintenanceStatus, useMarginRatio, useMarkPrice, useMarkPriceBySymbol, useMarkPricesStream, useMarket, useMarketList, useMarketMap, useMarketTradeStream, useMarkets, useMarketsStore, useMarketsStream, useMaxLeverage, useMaxQty, useMaxWithdrawal, useMediaQuery, useMemoizedFn, useMutation, useNetworkInfo, useOdosQuote, useOrderEntity, useOrderEntry2 as useOrderEntry, useOrderEntry as useOrderEntry_deprecated, useOrderStore2 as useOrderStore, useOrderStream, useOrderbookStream, useOrderlyContext, usePortfolio, usePositionActions, usePositionClose, usePositionStream, usePoster, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useRefereeHistory, useRefereeInfo, useRefereeRebateSummary, useReferralInfo, useReferralRebateSummary, useRestrictedInfo, useSessionStorage, useSettleSubscription, useSimpleDI, useStatisticsDaily, useStorageChain, useStorageLedgerAddress, useSubAccountDataObserver, useSubAccountMaxWithdrawal, useSubAccountMutation, useSubAccountQuery, useSubAccountWS, useSymbolInfo, useSymbolLeverage, useSymbolPriceRange, useSymbolsInfo, useSymbolsInfoStore, useTPSLOrder, useTickerStream, useTokenInfo, useTokensInfo, useTrack, useTrackingInstance, useTradingRewardsStatus, useTransfer, useTransferHistory, useUpdatedRef, useVaultsHistory, useWS, useWalletConnector, useWalletRewardsHistory, useWalletSubscription, useWalletTopic, useWithdraw, useWsStatus, utils_exports as utils, version_default as version };
17875
17799
  //# sourceMappingURL=out.js.map
17876
17800
  //# sourceMappingURL=index.mjs.map