This file contains hidden or 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
| import { | |
| convertToNumber, | |
| calculateBorrowRate, | |
| calculateDepositRate, | |
| PERCENTAGE_PRECISION, | |
| } from '@drift-labs/sdk'; | |
| const { driftClient } = await initDriftClients(process.env.RPC_URL!); | |
| const getApyFromApr = ( |
This file contains hidden or 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
| private async init() { | |
| this.userMap = new UserMap({ | |
| driftClient: this.driftClient, | |
| subscriptionConfig: { | |
| type: 'websocket', | |
| commitment: 'confirmed', | |
| }, | |
| includeIdle: false, | |
| skipInitialLoad: true, | |
| }); |
This file contains hidden or 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
| /** | |
| * add `"@drift-labs/sdk": "2.86.0-beta.6"` to package.json | |
| * | |
| * must set env vars before running: | |
| * * RPC_ENDPOINT: valid solana rpc | |
| * * ANCHOR_WALLET: private key file or raw string | |
| * | |
| * Usage: | |
| * ts-node settleUserPnl.ts | |
| * |
This file contains hidden or 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
| // dependencies: | |
| // "@solana/web3.js": "1.91.8", | |
| // "@coral-xyz/anchor": "^0.29.0", | |
| import * as bs58 from '@coral-xyz/anchor/dist/cjs/utils/bytes/bs58' | |
| import { | |
| Connection, | |
| VersionedTransaction, | |
| } from "@solana/web3.js"; |
This file contains hidden or 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
| import { | |
| DriftClient, | |
| AuctionSubscriber, | |
| Wallet, | |
| DRIFT_PROGRAM_ID, | |
| } from '@drift-labs/sdk' | |
| import { Connection, Keypair, PublicKey } from '@solana/web3.js'; | |
| const main = async () => { | |
| const connection = new Connection("ur own working rpc"); |
This file contains hidden or 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
| from solana.rpc.async_api import AsyncClient | |
| from solders.keypair import Keypair | |
| from anchorpy import Wallet | |
| from driftpy.drift_client import DriftClient | |
| from driftpy.account_subscription_config import AccountSubscriptionConfig | |
| from driftpy.events.event_subscriber import EventSubscriber | |
| from driftpy.events.types import WrappedEvent, EventSubscriptionOptions, WebsocketLogProviderConfig | |
| import os |
This file contains hidden or 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
| #!/Users/ww/.pyenv/versions/3.10.11/bin/python3 | |
| # Required parameters: | |
| # @raycast.schemaVersion 1 | |
| # @raycast.title Convert Solana Private Key | |
| # @raycast.mode fullOutput | |
| # Optional parameters: | |
| # @raycast.icon 🔒 | |
| # @raycast.argument1 { "type": "text", "placeholder": "Private key or filepath" } |
This file contains hidden or 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
| use std::error::Error; | |
| use anchor_client::{ | |
| anchor_lang::__private::base64, | |
| solana_sdk::{bs58, signature::Keypair}, | |
| }; | |
| pub fn read_keypair_str_multi_format(data: String) -> Result<Keypair, Box<dyn Error>> { | |
| // strip out any white spaces and new line/carriage return characters | |
| let data = data.replace([' ', '\n', '\r'], ""); |
This file contains hidden or 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
| import { Connection, Keypair, PublicKey } from '@solana/web3.js'; | |
| import { | |
| configs, | |
| DriftClient, | |
| Wallet, | |
| } from "@drift-labs/sdk"; | |
| async function main() { |
This file contains hidden or 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
| import { Connection, Keypair, PublicKey } from '@solana/web3.js'; | |
| import { | |
| BASE_PRECISION, | |
| BulkAccountLoader, | |
| configs, | |
| convertToNumber, | |
| DLOBSubscriber, | |
| DriftClient, | |
| getMarketsAndOraclesForSubscription, | |
| MarketType, |