@drift-labs/sdk 2.31.1-beta.26 → 2.31.1-beta.28

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 CHANGED
@@ -1 +1 @@
1
- 2.31.1-beta.26
1
+ 2.31.1-beta.28
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.31.1-beta.25",
2
+ "version": "2.31.1-beta.27",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
package/lib/index.d.ts CHANGED
@@ -16,6 +16,7 @@ export * from './accounts/pollingOracleAccountSubscriber';
16
16
  export * from './accounts/pollingTokenAccountSubscriber';
17
17
  export * from './accounts/pollingUserAccountSubscriber';
18
18
  export * from './accounts/pollingUserStatsAccountSubscriber';
19
+ export * from './accounts/mockUserAccountSubscriber';
19
20
  export * from './accounts/types';
20
21
  export * from './addresses/pda';
21
22
  export * from './adminClient';
package/lib/index.js CHANGED
@@ -39,6 +39,7 @@ __exportStar(require("./accounts/pollingOracleAccountSubscriber"), exports);
39
39
  __exportStar(require("./accounts/pollingTokenAccountSubscriber"), exports);
40
40
  __exportStar(require("./accounts/pollingUserAccountSubscriber"), exports);
41
41
  __exportStar(require("./accounts/pollingUserStatsAccountSubscriber"), exports);
42
+ __exportStar(require("./accounts/mockUserAccountSubscriber"), exports);
42
43
  __exportStar(require("./accounts/types"), exports);
43
44
  __exportStar(require("./addresses/pda"), exports);
44
45
  __exportStar(require("./adminClient"), exports);
package/lib/user.d.ts CHANGED
@@ -266,16 +266,12 @@ export declare class User {
266
266
  * @param outMarketIndex
267
267
  * @param calculateSwap function to similate in to out swa
268
268
  * @param iterationLimit how long to run appromixation before erroring out
269
- * @param inDelta how much to initially add to inAmount
270
- * @param outDelta how much to initially add to outAmount
271
269
  */
272
- getMaxSwapAmount({ inMarketIndex, outMarketIndex, calculateSwap, iterationLimit, inDelta, outDelta, }: {
270
+ getMaxSwapAmount({ inMarketIndex, outMarketIndex, calculateSwap, iterationLimit, }: {
273
271
  inMarketIndex: number;
274
272
  outMarketIndex: number;
275
273
  calculateSwap?: (inAmount: BN) => BN;
276
274
  iterationLimit?: number;
277
- inDelta?: BN;
278
- outDelta?: BN;
279
275
  }): {
280
276
  inAmount: BN;
281
277
  outAmount: BN;
package/lib/user.js CHANGED
@@ -1105,10 +1105,8 @@ class User {
1105
1105
  * @param outMarketIndex
1106
1106
  * @param calculateSwap function to similate in to out swa
1107
1107
  * @param iterationLimit how long to run appromixation before erroring out
1108
- * @param inDelta how much to initially add to inAmount
1109
- * @param outDelta how much to initially add to outAmount
1110
1108
  */
1111
- getMaxSwapAmount({ inMarketIndex, outMarketIndex, calculateSwap, iterationLimit = 1000, inDelta, outDelta, }) {
1109
+ getMaxSwapAmount({ inMarketIndex, outMarketIndex, calculateSwap, iterationLimit = 1000, }) {
1112
1110
  const inMarket = this.driftClient.getSpotMarketAccount(inMarketIndex);
1113
1111
  const outMarket = this.driftClient.getSpotMarketAccount(outMarketIndex);
1114
1112
  const inOraclePrice = this.getOracleDataForSpotMarket(inMarketIndex).price;
@@ -1116,16 +1114,10 @@ class User {
1116
1114
  const inPrecision = new _1.BN(10 ** inMarket.decimals);
1117
1115
  const outPrecision = new _1.BN(10 ** outMarket.decimals);
1118
1116
  const outSaferThanIn = inMarket.initialAssetWeight < outMarket.initialAssetWeight;
1119
- let inSpotPosition = this.getSpotPosition(inMarketIndex) ||
1117
+ const inSpotPosition = this.getSpotPosition(inMarketIndex) ||
1120
1118
  this.getEmptySpotPosition(inMarketIndex);
1121
- if (inDelta) {
1122
- inSpotPosition = this.cloneAndUpdateSpotPosition(inSpotPosition, inDelta, inMarket);
1123
- }
1124
- let outSpotPosition = this.getSpotPosition(outMarketIndex) ||
1119
+ const outSpotPosition = this.getSpotPosition(outMarketIndex) ||
1125
1120
  this.getEmptySpotPosition(outMarketIndex);
1126
- if (outDelta) {
1127
- outSpotPosition = this.cloneAndUpdateSpotPosition(outSpotPosition, outDelta, outMarket);
1128
- }
1129
1121
  const freeCollateral = this.getFreeCollateral();
1130
1122
  const inContributionInitial = this.calculateSpotPositionFreeCollateralContribution(inSpotPosition);
1131
1123
  const { totalAssetValue: inTotalAssetValueInitial, totalLiabilityValue: inTotalLiabilityValueInitial, } = this.calculateSpotPositionLeverageContribution(inSpotPosition);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.31.1-beta.26",
3
+ "version": "2.31.1-beta.28",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.31.1-beta.26",
2
+ "version": "2.31.1-beta.28",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
package/src/index.ts CHANGED
@@ -17,6 +17,7 @@ export * from './accounts/pollingOracleAccountSubscriber';
17
17
  export * from './accounts/pollingTokenAccountSubscriber';
18
18
  export * from './accounts/pollingUserAccountSubscriber';
19
19
  export * from './accounts/pollingUserStatsAccountSubscriber';
20
+ export * from './accounts/mockUserAccountSubscriber';
20
21
  export * from './accounts/types';
21
22
  export * from './addresses/pda';
22
23
  export * from './adminClient';
package/src/user.ts CHANGED
@@ -1987,23 +1987,17 @@ export class User {
1987
1987
  * @param outMarketIndex
1988
1988
  * @param calculateSwap function to similate in to out swa
1989
1989
  * @param iterationLimit how long to run appromixation before erroring out
1990
- * @param inDelta how much to initially add to inAmount
1991
- * @param outDelta how much to initially add to outAmount
1992
1990
  */
1993
1991
  public getMaxSwapAmount({
1994
1992
  inMarketIndex,
1995
1993
  outMarketIndex,
1996
1994
  calculateSwap,
1997
1995
  iterationLimit = 1000,
1998
- inDelta,
1999
- outDelta,
2000
1996
  }: {
2001
1997
  inMarketIndex: number;
2002
1998
  outMarketIndex: number;
2003
1999
  calculateSwap?: (inAmount: BN) => BN;
2004
2000
  iterationLimit?: number;
2005
- inDelta?: BN;
2006
- outDelta?: BN;
2007
2001
  }): { inAmount: BN; outAmount: BN; leverage: BN } {
2008
2002
  const inMarket = this.driftClient.getSpotMarketAccount(inMarketIndex);
2009
2003
  const outMarket = this.driftClient.getSpotMarketAccount(outMarketIndex);
@@ -2018,26 +2012,12 @@ export class User {
2018
2012
  const outSaferThanIn =
2019
2013
  inMarket.initialAssetWeight < outMarket.initialAssetWeight;
2020
2014
 
2021
- let inSpotPosition =
2015
+ const inSpotPosition =
2022
2016
  this.getSpotPosition(inMarketIndex) ||
2023
2017
  this.getEmptySpotPosition(inMarketIndex);
2024
- if (inDelta) {
2025
- inSpotPosition = this.cloneAndUpdateSpotPosition(
2026
- inSpotPosition,
2027
- inDelta,
2028
- inMarket
2029
- );
2030
- }
2031
- let outSpotPosition =
2018
+ const outSpotPosition =
2032
2019
  this.getSpotPosition(outMarketIndex) ||
2033
2020
  this.getEmptySpotPosition(outMarketIndex);
2034
- if (outDelta) {
2035
- outSpotPosition = this.cloneAndUpdateSpotPosition(
2036
- outSpotPosition,
2037
- outDelta,
2038
- outMarket
2039
- );
2040
- }
2041
2021
 
2042
2022
  const freeCollateral = this.getFreeCollateral();
2043
2023
 
@@ -2176,7 +2156,7 @@ export class User {
2176
2156
  return { inAmount: inSwap, outAmount: outSwap, leverage };
2177
2157
  }
2178
2158
 
2179
- cloneAndUpdateSpotPosition(
2159
+ public cloneAndUpdateSpotPosition(
2180
2160
  position: SpotPosition,
2181
2161
  tokenAmount: BN,
2182
2162
  market: SpotMarketAccount