@drift-labs/sdk 2.66.0-beta.0 → 2.66.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 CHANGED
@@ -1 +1 @@
1
- 2.66.0-beta.0
1
+ 2.66.0-beta.2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.66.0-beta.0",
3
+ "version": "2.66.0-beta.2",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
package/tests/amm/test.ts CHANGED
@@ -614,8 +614,14 @@ describe('AMM Tests', () => {
614
614
  // console.log(termsSuiExample);
615
615
  assert(termsSuiExample.effectiveLeverageCapped <= 1.000001);
616
616
  assert(termsSuiExample.inventorySpreadScale == 1.00007);
617
- assert(termsSuiExample.longSpread == 259073);
618
- assert(termsSuiExample.shortSpread == 3712);
617
+ assert(
618
+ termsSuiExample.longSpread == 269818,
619
+ `SUI long spread got ${termsSuiExample.longSpread}`
620
+ );
621
+ assert(
622
+ termsSuiExample.shortSpread == 3920,
623
+ `SUI short spread got ${termsSuiExample.shortSpread}`
624
+ );
619
625
 
620
626
  // reset amm reserves/peg to balanced values s.t. liquidity/price is the same
621
627
  // to avoid error prone int math
@@ -674,7 +680,26 @@ describe('AMM Tests', () => {
674
680
  );
675
681
 
676
682
  console.log(termsSuiExampleMod2);
677
- // assert(_.isEqual(termsSuiExampleMod2, termsSuiExampleMod1));
683
+ assert(
684
+ _.isEqual(
685
+ termsSuiExampleMod2.maxTargetSpread,
686
+ termsSuiExampleMod1.maxTargetSpread
687
+ )
688
+ );
689
+ assert(
690
+ _.isEqual(
691
+ termsSuiExampleMod2.shortSpreadwPS,
692
+ termsSuiExampleMod1.shortSpreadwPS
693
+ )
694
+ );
695
+ assert(
696
+ _.isEqual(
697
+ termsSuiExampleMod2.longSpreadwPS,
698
+ termsSuiExampleMod1.longSpreadwPS
699
+ )
700
+ );
701
+
702
+ // note: effectiveLeverage as currently implemented is sensitive to peg change
678
703
  });
679
704
 
680
705
  it('Spread Reserves (with offset)', () => {
@@ -24,6 +24,7 @@ import {
24
24
  SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION,
25
25
  SPOT_MARKET_WEIGHT_PRECISION,
26
26
  PRICE_PRECISION,
27
+ DataAndSlot,
27
28
  } from '../../src';
28
29
 
29
30
  export const mockPerpPosition: PerpPosition = {
@@ -639,6 +640,10 @@ export class MockUserMap implements UserMapInterface {
639
640
  return undefined;
640
641
  }
641
642
 
643
+ public getWithSlot(_key: string): DataAndSlot<User> | undefined {
644
+ return undefined;
645
+ }
646
+
642
647
  public async mustGet(_key: string): Promise<User> {
643
648
  return new User({
644
649
  driftClient: this.driftClient,
@@ -646,6 +651,16 @@ export class MockUserMap implements UserMapInterface {
646
651
  });
647
652
  }
648
653
 
654
+ public async mustGetWithSlot(_key: string): Promise<DataAndSlot<User>> {
655
+ return {
656
+ data: new User({
657
+ driftClient: this.driftClient,
658
+ userAccountPublicKey: PublicKey.default,
659
+ }),
660
+ slot: 0,
661
+ };
662
+ }
663
+
649
664
  public getUserAuthority(key: string): PublicKey | undefined {
650
665
  return new PublicKey(
651
666
  this.userAccountToAuthority.get(key) || PublicKey.default.toBase58()
@@ -657,4 +672,29 @@ export class MockUserMap implements UserMapInterface {
657
672
  public values(): IterableIterator<User> {
658
673
  return this.userMap.values();
659
674
  }
675
+
676
+ public *valuesWithSlot(): IterableIterator<DataAndSlot<User>> {
677
+ for (const user of this.userMap.values()) {
678
+ yield {
679
+ data: user,
680
+ slot: 0,
681
+ };
682
+ }
683
+ }
684
+
685
+ public entries(): IterableIterator<[string, User]> {
686
+ return this.userMap.entries();
687
+ }
688
+
689
+ public *entriesWithSlot(): IterableIterator<[string, DataAndSlot<User>]> {
690
+ for (const [key, user] of this.userMap.entries()) {
691
+ yield [
692
+ key,
693
+ {
694
+ data: user,
695
+ slot: 0,
696
+ },
697
+ ];
698
+ }
699
+ }
660
700
  }