@drift-labs/sdk 2.66.0-beta.0 → 2.66.0-beta.1
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/package.json +1 -1
- package/tests/amm/test.ts +8 -2
- package/tests/dlob/helpers.ts +40 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.66.0-beta.
|
|
1
|
+
2.66.0-beta.1
|
package/package.json
CHANGED
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(
|
|
618
|
-
|
|
617
|
+
assert(
|
|
618
|
+
termsSuiExample.longSpread == 259073,
|
|
619
|
+
`SUI long spread got ${termsSuiExample.longSpread}`
|
|
620
|
+
);
|
|
621
|
+
assert(
|
|
622
|
+
termsSuiExample.shortSpread == 3712,
|
|
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
|
package/tests/dlob/helpers.ts
CHANGED
|
@@ -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
|
}
|