-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
3,668 additions
and
821 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} |
Oops, something went wrong.