@depthhq/sdk 0.1.9 → 0.1.11
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.js +10 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -47861,7 +47861,6 @@ class DepthClient {
|
|
|
47861
47861
|
const currentSide = position.position > 0n ? "long" : "short";
|
|
47862
47862
|
const direction = intent === "reduce" || intent === "close" ? currentSide === "long" ? "short" : "long" : input.direction;
|
|
47863
47863
|
encodeSide(direction);
|
|
47864
|
-
const worstPriceE8 = tradeLimit(input, direction, BigInt(market.state.oraclePriceE8.toString()));
|
|
47865
47864
|
if ((intent === "reduce" || intent === "close" || intent === "reverse") && position.position === 0n)
|
|
47866
47865
|
throw new Error("There is no position to manage");
|
|
47867
47866
|
if (intent === "increase" && position.position !== 0n && direction !== currentSide)
|
|
@@ -47873,6 +47872,15 @@ class DepthClient {
|
|
|
47873
47872
|
u64(position.collateral, "collateral");
|
|
47874
47873
|
if (position.collateral === 0n)
|
|
47875
47874
|
throw new Error("The market account has no collateral");
|
|
47875
|
+
const mxePublicKey = await getMXEPublicKey(this.provider, DEPTH_PROGRAM_ID9);
|
|
47876
|
+
if (!mxePublicKey)
|
|
47877
|
+
throw new Error("MXE public key is unavailable");
|
|
47878
|
+
const secret = x25519.utils.randomSecretKey();
|
|
47879
|
+
const inputKey = x25519.getPublicKey(secret);
|
|
47880
|
+
const inputNonce = randomBytes3(16);
|
|
47881
|
+
const cipher = new RescueCipher(x25519.getSharedSecret(secret, mxePublicKey));
|
|
47882
|
+
const offset2 = nonce();
|
|
47883
|
+
const queue = await this.queue("match_order", offset2);
|
|
47876
47884
|
let keys = [];
|
|
47877
47885
|
const quoteDeadline = Date.now() + 60000;
|
|
47878
47886
|
for (;; ) {
|
|
@@ -47897,13 +47905,7 @@ class DepthClient {
|
|
|
47897
47905
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
47898
47906
|
}
|
|
47899
47907
|
}
|
|
47900
|
-
const
|
|
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));
|
|
47908
|
+
const worstPriceE8 = tradeLimit(input, direction, BigInt(market.state.oraclePriceE8.toString()));
|
|
47907
47909
|
const ciphertexts = cipher.encrypt(circuits2.OrderInput.pack({
|
|
47908
47910
|
side: encodeSide(direction),
|
|
47909
47911
|
amount,
|
|
@@ -47913,8 +47915,6 @@ class DepthClient {
|
|
|
47913
47915
|
intent: BigInt(["increase", "reduce", "close", "reverse"].indexOf(intent)),
|
|
47914
47916
|
version: position.version
|
|
47915
47917
|
}), 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,
|