Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdk: npm publish #374

Merged
merged 5 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr_build_cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install
run: pnpm install && pnpm install --filter @glamsystems/glam-sdk

- name: Build
run: pnpm run cli-build
2 changes: 1 addition & 1 deletion .github/workflows/pr_build_dapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install
run: pnpm install && pnpm install --filter @glamsystems/glam-sdk

- name: Build
run: pnpm run build
53 changes: 53 additions & 0 deletions anchor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# GLAM SDK

A TypeScript SDK for interacting with the GLAM Protocol.

## Installation

```bash
npm i @glamsystems/glam-sdk
```

## Getting Started

- [GLAM docs](https://docs.glam.systems)
- [TypeScript API docs](#)

## Examples

### Set up a GLAM client and interact with a vault

```ts
import * as anchor from "@coral-xyz/anchor";
import { GlamClient, WSOL } from "@glamsystems/glam-sdk";
import { PublicKey } from "@solana/web3.js";

// Need to set ANCHOR_PROVIDER_URL and ANCHOR_WALLET env variables
// ANCHOR_PROVIDER_URL=...
// ANCHOR_WALLET=...
const glamClient = new GlamClient();
const statePda = new PublicKey("FMHLPaEeCbuivqsAfHrr28FpWJ9oKHTx3jzFbb3tYhq4");

async function main() {
const vaultPda = glamClient.getVaultPda(statePda);

console.log("statePda:", statePda.toBase58());
console.log("vaultPda:", vaultPda.toBase58());

const vaultWsolBalance = await glamClient.getVaultTokenBalance(statePda, WSOL);
console.log("vaultWsolBalance:", vaultWsolBalance.toString());

// Wrap 0.1 SOL
const txSig = await glamClient.wsol.wrap(statePda, new anchor.BN(100_000_000));
console.log("txSig:", txSig);

// wSOL balance after wrap should increase by 0.1 SOL
const vaultWsolBalanceAfter = await glamClient.getVaultTokenBalance(statePda, WSOL);
console.log("vaultWsolBalanceAfter:", vaultWsolBalanceAfter.toString());
}

main().catch((error) => {
console.error("Error:", error);
process.exit(1);
});
```
50 changes: 45 additions & 5 deletions anchor/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,48 @@
{
"name": "@glam/anchor",
"version": "0.0.1",
"dependencies": {},
"type": "commonjs",
"name": "@glamsystems/glam-sdk",
"version": "0.1.5",
"description": "TypeScript SDK for GLAM Protocol",
"main": "./index.cjs",
"module": "./index.js"
"module": "./index.esm.js",
"homepage": "https://www.glam.systems",
"repository": {
"type": "git",
"url": "[email protected]:glamsystems/glam.git"
},
"keywords": [
"glam-protocol",
"solana"
],
"license": "Apache-2.0",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@coral-xyz/anchor": "^0.30.1",
"@drift-labs/sdk": "2.96.0-beta.14",
"@marinade.finance/marinade-ts-sdk": "^5.0.15",
"@pythnetwork/client": "^2.21.1",
"@solana/spl-stake-pool": "^1.1.5",
"@solana/spl-token": "^0.4.9",
"@solana/spl-token-metadata": "^0.1.4",
"@solana/web3.js": "^1.98.0",
"bs58": "^5.0.0",
"buffer": "^6.0.3"
},
"engines": {
"node": ">=20.18.0"
},
"devDependencies": {
"@rollup/plugin-terser": "^0.4.4",
"rollup-plugin-javascript-obfuscator": "^1.0.4"
},
"pnpm": {
"overrides": {
"@solana/web3.js@>=0.0.1": "^1.98.0",
"@solana/spl-token@>=0.0.1": "^0.3.9",
"@solana/spl-stake-pool@>=0.0.1": "^1.1.5",
"typescript@>=0.0.1": "^5.5.3",
"solana-bankrun@>=0.0.1": "^0.3.0"
}
}
}
Loading
Loading