@quartz-labs/sdk 0.0.2 → 0.0.4
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/{build → dist}/client.d.ts +1 -1
- package/{build → dist}/client.js +5 -5
- package/{build → dist}/config/constants.d.ts +2 -0
- package/{src/config/constants.ts → dist/config/constants.js} +1 -5
- package/{src/index.ts → dist/index.d.ts} +1 -2
- package/{build → dist}/index.js +1 -1
- package/{build → dist}/model/driftUser.d.ts +3 -0
- package/{build → dist}/model/driftUser.js +9 -2
- package/dist/user.d.ts +25 -0
- package/dist/user.js +158 -0
- package/dist/utils/helpers.d.ts +12 -0
- package/{build → dist/utils}/helpers.js +8 -8
- package/dist/utils/jupiter.d.ts +7 -0
- package/dist/utils/jupiter.js +48 -0
- package/package.json +6 -10
- package/build/config/constants.js +0 -7
- package/build/helpers.d.ts +0 -12
- package/build/index.d.ts +0 -4
- package/build/user.d.ts +0 -16
- package/build/user.js +0 -47
- package/jest.config.js +0 -4
- package/src/client.ts +0 -119
- package/src/idl/quartz.json +0 -646
- package/src/model/driftUser.ts +0 -1066
- package/src/services/driftClientService.ts +0 -37
- package/src/tests/helpers.test.ts +0 -48
- package/src/types/quartz.ts +0 -1293
- package/src/user.ts +0 -227
- package/src/utils/helpers.ts +0 -68
- package/src/utils/jupiter.ts +0 -73
- package/tsconfig.json +0 -17
- /package/{build → dist}/idl/quartz.json +0 -0
- /package/{build → dist}/services/driftClientService.d.ts +0 -0
- /package/{build → dist}/services/driftClientService.js +0 -0
- /package/{build → dist}/types/quartz.d.ts +0 -0
- /package/{build → dist}/types/quartz.js +0 -0
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { DriftClient, Wallet } from "@drift-labs/sdk";
|
|
2
|
-
import { Connection, Keypair } from "@solana/web3.js";
|
|
3
|
-
import { SUPPORTED_DRIFT_MARKETS } from "../config/constants.js";
|
|
4
|
-
|
|
5
|
-
export class DriftClientService {
|
|
6
|
-
private static instance: DriftClientService;
|
|
7
|
-
private driftClient: DriftClient;
|
|
8
|
-
private driftClientInitPromise: Promise<boolean>;
|
|
9
|
-
|
|
10
|
-
constructor(
|
|
11
|
-
connection: Connection
|
|
12
|
-
) {
|
|
13
|
-
const wallet = new Wallet(Keypair.generate());
|
|
14
|
-
|
|
15
|
-
this.driftClient = new DriftClient({
|
|
16
|
-
connection: connection,
|
|
17
|
-
wallet: wallet,
|
|
18
|
-
env: 'mainnet-beta',
|
|
19
|
-
userStats: false,
|
|
20
|
-
perpMarketIndexes: [],
|
|
21
|
-
spotMarketIndexes: SUPPORTED_DRIFT_MARKETS,
|
|
22
|
-
accountSubscription: {
|
|
23
|
-
type: 'websocket',
|
|
24
|
-
commitment: "confirmed"
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
this.driftClientInitPromise = this.driftClient.subscribe();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public static async getDriftClient(connection: Connection): Promise<DriftClient> {
|
|
31
|
-
if (!DriftClientService.instance) {
|
|
32
|
-
DriftClientService.instance = new DriftClientService(connection);
|
|
33
|
-
}
|
|
34
|
-
await DriftClientService.instance.driftClientInitPromise;
|
|
35
|
-
return DriftClientService.instance.driftClient;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { PublicKey } from "@solana/web3.js";
|
|
2
|
-
import { getDriftSpotMarketPublicKey, getDriftStatePublicKey, getDriftUserPublicKey, getDriftUserStatsPublicKey, getVaultPublicKey, getVaultSplPublicKey } from "../utils/helpers";
|
|
3
|
-
import { DRIFT_MARKET_INDEX_SOL, DRIFT_MARKET_INDEX_USDC, USDC_MINT, WSOL_MINT } from "../config/constants";
|
|
4
|
-
|
|
5
|
-
describe("PDAs", () => {
|
|
6
|
-
const testAddress = new PublicKey("DcJpAhpbhwgXF5UBJP1KN6ub4GS61TmAb32LtoB57pAf");
|
|
7
|
-
|
|
8
|
-
it("Should get user vault", () => {
|
|
9
|
-
const vault = getVaultPublicKey(testAddress);
|
|
10
|
-
|
|
11
|
-
expect(vault).toStrictEqual(new PublicKey("D9RiL1Hs2mZs8VWT2vAbYBfspxk2j3iY51VDfeFooDqL"));
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("Should get user USDC vault", () => {
|
|
15
|
-
const vaultSpl = getVaultSplPublicKey(testAddress, USDC_MINT);
|
|
16
|
-
expect(vaultSpl).toStrictEqual(new PublicKey("HWaxYwwvUtT7zYXkCn1GfpsjX8hgdVv6i4mWxpPbLMgn"));
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("Should get user wSOL vault", () => {
|
|
20
|
-
const vaultSpl = getVaultSplPublicKey(testAddress, WSOL_MINT);
|
|
21
|
-
expect(vaultSpl).toStrictEqual(new PublicKey("A8ZVAarQAQWTbnQdnmhiEbpewDZYnTUrMWivz55L6LCP"));
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("Should get drift user", () => {
|
|
25
|
-
const driftUser = getDriftUserPublicKey(getVaultPublicKey(testAddress));
|
|
26
|
-
expect(driftUser).toStrictEqual(new PublicKey("7ZpTwFDpbcFWY4tY8SwpTnD79JYtCgytXBM3T8Fukgcy"));
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it("Should get drift user stats", () => {
|
|
30
|
-
const driftUserStats = getDriftUserStatsPublicKey(getVaultPublicKey(testAddress));
|
|
31
|
-
expect(driftUserStats).toStrictEqual(new PublicKey("4Kuz1AAF9DMYcrpQESbjG49VVqZW9J9pjiZZySaKVnUE"));
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
it("Should get drift state", () => {
|
|
35
|
-
const driftState = getDriftStatePublicKey();
|
|
36
|
-
expect(driftState).toStrictEqual(new PublicKey("5zpq7DvB6UdFFvpmBPspGPNfUGoBRRCE2HHg5u3gxcsN"));
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it("Should get drift spot market USDC vault", () => {
|
|
40
|
-
const driftSpotMarketVault = getDriftSpotMarketPublicKey(DRIFT_MARKET_INDEX_USDC);
|
|
41
|
-
expect(driftSpotMarketVault).toStrictEqual(new PublicKey("GXWqPpjQpdz7KZw9p7f5PX2eGxHAhvpNXiviFkAB8zXg"));
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
it("Should get drift spot market SOL vault", () => {
|
|
45
|
-
const driftSpotMarketVault = getDriftSpotMarketPublicKey(DRIFT_MARKET_INDEX_SOL);
|
|
46
|
-
expect(driftSpotMarketVault).toStrictEqual(new PublicKey("DfYCNezifxAEsQbAJ1b3j6PX3JVBe8fu11KBhxsbw5d2"));
|
|
47
|
-
})
|
|
48
|
-
});
|