@glamsystems/glam-sdk 0.1.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/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # GLAM SDK
2
+
3
+ A TypeScript SDK for interacting with the GLAM Protocol.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm i @glamsystems/glam-sdk
9
+ ```
10
+
11
+ ## Getting Started
12
+
13
+ - [GLAM docs](https://docs.glam.systems)
14
+ - [TypeScript API docs](#)
15
+
16
+ ## Examples
17
+
18
+ ### Setting up a GLAM client and
19
+
20
+ ```ts
21
+ import * as anchor from "@coral-xyz/anchor";
22
+ import { GlamClient, WSOL } from "@glamsystems/glam-sdk";
23
+ import { PublicKey } from "@solana/web3.js";
24
+
25
+ // Need to set ANCHOR_PROVIDER_URL and ANCHOR_WALLET env variables
26
+ // ANCHOR_PROVIDER_URL=...
27
+ // ANCHOR_WALLET=...
28
+ const glamClient = new GlamClient();
29
+ const statePda = new PublicKey("FMHLPaEeCbuivqsAfHrr28FpWJ9oKHTx3jzFbb3tYhq4");
30
+
31
+ async function main() {
32
+ const vaultPda = glamClient.getVaultPda(statePda);
33
+
34
+ console.log("statePda:", statePda.toBase58());
35
+ console.log("vaultPda:", vaultPda.toBase58());
36
+
37
+ const vaultWsolBalance = await glamClient.getVaultTokenBalance(statePda, WSOL);
38
+ console.log("vaultWsolBalance:", vaultWsolBalance.toString());
39
+
40
+ // Wrap 0.1 SOL
41
+ const txSig = await glamClient.wsol.wrap(statePda, new anchor.BN(100_000_000));
42
+ console.log("txSig:", txSig);
43
+
44
+ // wSOL balance after wrap should increase by 0.1 SOL
45
+ const vaultWsolBalanceAfter = await glamClient.getVaultTokenBalance(statePda, WSOL);
46
+ console.log("vaultWsolBalanceAfter:", vaultWsolBalanceAfter.toString());
47
+ }
48
+
49
+ main().catch((error) => {
50
+ console.error("Error:", error);
51
+ process.exit(1);
52
+ });
53
+ ```
package/index.cjs.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src/index";