@quartz-labs/sdk 0.0.5 → 0.0.6
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/dist/client.d.ts +4 -4
- package/dist/client.js +9 -7
- package/dist/user.d.ts +2 -2
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ export declare class QuartzClient {
|
|
|
12
12
|
private driftClient;
|
|
13
13
|
private oracles;
|
|
14
14
|
constructor(connection: Connection, wallet: Wallet, program: Program<Quartz>, quartzAddressTable: AddressLookupTableAccount, driftClient: DriftClient, oracles: Map<string, PublicKey>);
|
|
15
|
-
static
|
|
16
|
-
|
|
17
|
-
getQuartzAccount(
|
|
18
|
-
getMultipleQuartzAccounts(
|
|
15
|
+
static fetchClient(connection: Connection, wallet: Wallet): Promise<QuartzClient>;
|
|
16
|
+
getAllQuartzAccountOwnerPubkeys(): Promise<PublicKey[]>;
|
|
17
|
+
getQuartzAccount(owner: PublicKey): Promise<QuartzUser>;
|
|
18
|
+
getMultipleQuartzAccounts(owners: PublicKey[]): Promise<(QuartzUser | null)[]>;
|
|
19
19
|
}
|
package/dist/client.js
CHANGED
|
@@ -4,7 +4,7 @@ import quartzIdl from "./idl/quartz.json";
|
|
|
4
4
|
import { AnchorProvider, Program, setProvider } from "@coral-xyz/anchor";
|
|
5
5
|
import { PythSolanaReceiver } from "@pythnetwork/pyth-solana-receiver";
|
|
6
6
|
import { QuartzUser } from "./user";
|
|
7
|
-
import { getDriftUserPublicKey } from "./utils/helpers";
|
|
7
|
+
import { getDriftUserPublicKey, getVaultPublicKey } from "./utils/helpers";
|
|
8
8
|
import { DriftClientService } from "./services/driftClientService";
|
|
9
9
|
export class QuartzClient {
|
|
10
10
|
constructor(connection, wallet, program, quartzAddressTable, driftClient, oracles) {
|
|
@@ -15,7 +15,7 @@ export class QuartzClient {
|
|
|
15
15
|
this.driftClient = driftClient;
|
|
16
16
|
this.oracles = oracles;
|
|
17
17
|
}
|
|
18
|
-
static async
|
|
18
|
+
static async fetchClient(connection, wallet) {
|
|
19
19
|
const provider = new AnchorProvider(connection, wallet, { commitment: "confirmed" });
|
|
20
20
|
setProvider(provider);
|
|
21
21
|
const program = new Program(quartzIdl, QUARTZ_PROGRAM_ID, provider);
|
|
@@ -30,16 +30,18 @@ export class QuartzClient {
|
|
|
30
30
|
]);
|
|
31
31
|
return new QuartzClient(connection, wallet, program, quartzLookupTable, driftClient, oracles);
|
|
32
32
|
}
|
|
33
|
-
async
|
|
34
|
-
return (await this.program.account.vault.all()).map((vault) => vault.
|
|
33
|
+
async getAllQuartzAccountOwnerPubkeys() {
|
|
34
|
+
return (await this.program.account.vault.all()).map((vault) => vault.account.owner);
|
|
35
35
|
}
|
|
36
|
-
async getQuartzAccount(
|
|
36
|
+
async getQuartzAccount(owner) {
|
|
37
|
+
const vault = getVaultPublicKey(owner);
|
|
37
38
|
await this.program.account.vault.fetch(vault); // Check account exists
|
|
38
39
|
return new QuartzUser(vault, this.connection, this.program, this.quartzLookupTable, this.oracles, this.driftClient);
|
|
39
40
|
}
|
|
40
|
-
async getMultipleQuartzAccounts(
|
|
41
|
-
if (
|
|
41
|
+
async getMultipleQuartzAccounts(owners) {
|
|
42
|
+
if (owners.length === 0)
|
|
42
43
|
return [];
|
|
44
|
+
const vaults = owners.map((owner) => getVaultPublicKey(owner));
|
|
43
45
|
const accounts = await this.program.account.vault.fetchMultiple(vaults);
|
|
44
46
|
accounts.forEach((account, index) => {
|
|
45
47
|
if (account === null)
|
package/dist/user.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { Connection } from "@solana/web3.js";
|
|
|
4
4
|
import { Quartz } from "./types/quartz";
|
|
5
5
|
import { Program } from "@coral-xyz/anchor";
|
|
6
6
|
export declare class QuartzUser {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
readonly pubkey: PublicKey;
|
|
8
|
+
readonly vaultPubkey: PublicKey;
|
|
9
9
|
private connection;
|
|
10
10
|
private program;
|
|
11
11
|
private quartzLookupTable;
|