@depthhq/sdk 0.1.9 → 0.1.10

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -18
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -47873,6 +47873,24 @@ class DepthClient {
47873
47873
  u64(position.collateral, "collateral");
47874
47874
  if (position.collateral === 0n)
47875
47875
  throw new Error("The market account has no collateral");
47876
+ const mxePublicKey = await getMXEPublicKey(this.provider, DEPTH_PROGRAM_ID9);
47877
+ if (!mxePublicKey)
47878
+ throw new Error("MXE public key is unavailable");
47879
+ const secret = x25519.utils.randomSecretKey();
47880
+ const inputKey = x25519.getPublicKey(secret);
47881
+ const inputNonce = randomBytes3(16);
47882
+ const cipher = new RescueCipher(x25519.getSharedSecret(secret, mxePublicKey));
47883
+ const ciphertexts = cipher.encrypt(circuits2.OrderInput.pack({
47884
+ side: encodeSide(direction),
47885
+ amount,
47886
+ margin: position.collateral,
47887
+ limit_price: worstPriceE8,
47888
+ max_fee: input.maxFee,
47889
+ intent: BigInt(["increase", "reduce", "close", "reverse"].indexOf(intent)),
47890
+ version: position.version
47891
+ }), inputNonce);
47892
+ const offset2 = nonce();
47893
+ const queue = await this.queue("match_order", offset2);
47876
47894
  let keys = [];
47877
47895
  const quoteDeadline = Date.now() + 60000;
47878
47896
  for (;; ) {
@@ -47897,24 +47915,6 @@ class DepthClient {
47897
47915
  await new Promise((resolve) => setTimeout(resolve, 1000));
47898
47916
  }
47899
47917
  }
47900
- const mxePublicKey = await getMXEPublicKey(this.provider, DEPTH_PROGRAM_ID9);
47901
- if (!mxePublicKey)
47902
- throw new Error("MXE public key is unavailable");
47903
- const secret = x25519.utils.randomSecretKey();
47904
- const inputKey = x25519.getPublicKey(secret);
47905
- const inputNonce = randomBytes3(16);
47906
- const cipher = new RescueCipher(x25519.getSharedSecret(secret, mxePublicKey));
47907
- const ciphertexts = cipher.encrypt(circuits2.OrderInput.pack({
47908
- side: encodeSide(direction),
47909
- amount,
47910
- margin: position.collateral,
47911
- limit_price: worstPriceE8,
47912
- max_fee: input.maxFee,
47913
- intent: BigInt(["increase", "reduce", "close", "reverse"].indexOf(intent)),
47914
- version: position.version
47915
- }), inputNonce);
47916
- const offset2 = nonce();
47917
- const queue = await this.queue("match_order", offset2);
47918
47918
  const signature = await this.program.methods.submitOrder(offset2, orderNonce, appId, app.feeBps, app.version, new anchor9.BN(deadline), market.state.revision, market.state.oracleTimestamp, ciphertexts, Array.from(inputKey), new anchor9.BN(inputNonce, "le")).accountsPartial({
47919
47919
  ...queue,
47920
47920
  trader: this.options.wallet.publicKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depthhq/sdk",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -44,8 +44,8 @@
44
44
  "@noble/hashes": "1.8.0",
45
45
  "@solana/web3.js": "1.99.0",
46
46
  "buffer": "6.0.3",
47
- "@depthhq/bindings": "0.1.5",
48
- "@depthhq/schema": "0.1.2"
47
+ "@depthhq/schema": "0.1.2",
48
+ "@depthhq/bindings": "0.1.5"
49
49
  },
50
50
  "devDependencies": {
51
51
  "fake-indexeddb": "6.2.4"