@drift-labs/sdk 2.61.0-beta.0 → 2.61.0-beta.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/VERSION +1 -1
- package/lib/oracles/pythClient.js +2 -1
- package/lib/user.js +1 -1
- package/package.json +1 -1
- package/src/oracles/pythClient.ts +2 -1
- package/src/user.ts +1 -1
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.61.0-beta.
|
|
1
|
+
2.61.0-beta.2
|
|
@@ -17,6 +17,7 @@ class PythClient {
|
|
|
17
17
|
getOraclePriceDataFromBuffer(buffer) {
|
|
18
18
|
const priceData = (0, client_1.parsePriceData)(buffer);
|
|
19
19
|
const confidence = convertPythPrice(priceData.confidence, priceData.exponent, this.multiple);
|
|
20
|
+
const minPublishers = Math.min(priceData.numComponentPrices, 3);
|
|
20
21
|
let price = convertPythPrice(priceData.aggregate.price, priceData.exponent, this.multiple);
|
|
21
22
|
if (this.stableCoin) {
|
|
22
23
|
price = getStableCoinPrice(price, confidence);
|
|
@@ -27,7 +28,7 @@ class PythClient {
|
|
|
27
28
|
confidence,
|
|
28
29
|
twap: convertPythPrice(priceData.twap.value, priceData.exponent, this.multiple),
|
|
29
30
|
twapConfidence: convertPythPrice(priceData.twac.value, priceData.exponent, this.multiple),
|
|
30
|
-
hasSufficientNumberOfDataPoints:
|
|
31
|
+
hasSufficientNumberOfDataPoints: priceData.numQuoters >= minPublishers,
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
34
|
}
|
package/lib/user.js
CHANGED
|
@@ -66,7 +66,7 @@ class User {
|
|
|
66
66
|
return this.accountSubscriber.getUserAccountAndSlot();
|
|
67
67
|
}
|
|
68
68
|
getPerpPositionForUserAccount(userAccount, marketIndex) {
|
|
69
|
-
return userAccount.
|
|
69
|
+
return this.getActivePerpPositionsForUserAccount(userAccount).find((position) => position.marketIndex === marketIndex);
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
72
|
* Gets the user's current position for a given perp market. If the user has no position returns undefined
|
package/package.json
CHANGED
|
@@ -38,6 +38,7 @@ export class PythClient implements OracleClient {
|
|
|
38
38
|
priceData.exponent,
|
|
39
39
|
this.multiple
|
|
40
40
|
);
|
|
41
|
+
const minPublishers = Math.min(priceData.numComponentPrices, 3);
|
|
41
42
|
let price = convertPythPrice(
|
|
42
43
|
priceData.aggregate.price,
|
|
43
44
|
priceData.exponent,
|
|
@@ -61,7 +62,7 @@ export class PythClient implements OracleClient {
|
|
|
61
62
|
priceData.exponent,
|
|
62
63
|
this.multiple
|
|
63
64
|
),
|
|
64
|
-
hasSufficientNumberOfDataPoints:
|
|
65
|
+
hasSufficientNumberOfDataPoints: priceData.numQuoters >= minPublishers,
|
|
65
66
|
};
|
|
66
67
|
}
|
|
67
68
|
}
|
package/src/user.ts
CHANGED
|
@@ -162,7 +162,7 @@ export class User {
|
|
|
162
162
|
userAccount: UserAccount,
|
|
163
163
|
marketIndex: number
|
|
164
164
|
): PerpPosition | undefined {
|
|
165
|
-
return userAccount.
|
|
165
|
+
return this.getActivePerpPositionsForUserAccount(userAccount).find(
|
|
166
166
|
(position) => position.marketIndex === marketIndex
|
|
167
167
|
);
|
|
168
168
|
}
|