@deriverse/sqds-admin-kit
v1.0.8
Published
TypeScript SDK for Deriverse protocol administration via Squads multisig on Solana
Readme
@deriverse/sqds-admin-kit
TypeScript SDK for Deriverse protocol administration via Squads multisig on Solana.
Features
- Create Squads multisig transactions for Deriverse protocol operations
- Type-safe interface with full TypeScript support
- Dual ESM/CommonJS module support
- Comprehensive documentation with JSDoc comments
Installation
npm install @deriverse/sqds-admin-kit
# or
yarn add @deriverse/sqds-admin-kit
# or
pnpm add @deriverse/sqds-admin-kitRequirements
- Node.js >= 18.0.0
@solana/web3.js>= 1.90.0 (peer dependency)
Quick Start
import { AdminEngine } from '@deriverse/sqds-admin-kit';
import { Connection, PublicKey } from '@solana/web3.js';
// Initialize connection
const connection = new Connection('https://api.mainnet-beta.solana.com');
// Create AdminEngine instance
const engine = new AdminEngine({
connection,
proposer: new PublicKey('YOUR_PROPOSER_PUBKEY'),
});
// Create a multisig transaction instruction
const instruction = await engine.newHolderAccountInstruction();API Reference
AdminEngine
The main class for interacting with the Deriverse protocol via Squads multisig.
Constructor
const engine = new AdminEngine({
connection: Connection, // Solana RPC connection
proposer: PublicKey, // Transaction proposer public key
programId?: PublicKey, // Optional: Custom program ID (defaults to mainnet)
holderMultisigPda?: PublicKey, // Optional: Holder multisig PDA
operatorMultisigPda?: PublicKey, // Optional: Operator multisig PDA
clientMultisigPda?: PublicKey, // Optional: Client multisig PDA
holderVaultIndex?: number, // Optional: Holder vault index (default: 0)
operatorVaultIndex?: number, // Optional: Operator vault index (default: 0)
clientVaultIndex?: number, // Optional: Client vault index (default: 0)
privateModeAuthority?: PublicKey, // Optional: Private mode authority
drvsMint?: PublicKey, // Optional: DRVS mint address
version?: number, // Optional: Protocol version
});Holder Operations
newHolderAccountInstruction()
Create a new holder account.
const ix = await engine.newHolderAccountInstruction();newOperatorInstruction()
Add a new operator to the protocol.
const ix = await engine.newOperatorInstruction();Operator Operations
newRootAccountInstruction(args?)
Initialize the root account.
const ix = await engine.newRootAccountInstruction({
privateMode: true, // Enable private mode
});newBaseCurrencyInstruction(args?)
Add a new base currency to the protocol.
import { USDC_MINT } from '@deriverse/sqds-admin-kit';
const ix = await engine.newBaseCurrencyInstruction({
newBaseCrncyMint: USDC_MINT,
});setVarianceInstruction(args)
Set variance for an instrument.
const ix = await engine.setVarianceInstruction({
assetTokenId: 1,
crncyTokenId: 0,
variance: 0.04, // 4%
});setInstrReadyForPerpUpgradeInstruction(args)
Mark an instrument as ready for perpetual upgrade.
const ix = await engine.setInstrReadyForPerpUpgradeInstruction({
assetTokenId: 1,
crncyTokenId: 0,
});terminatePrivateModeInstruction()
Terminate private mode.
const ix = await engine.terminatePrivateModeInstruction();changePrivateModeAuthorityInstruction(args)
Change the private mode authority.
const ix = await engine.changePrivateModeAuthorityInstruction({
authority: new PublicKey('NEW_AUTHORITY'),
});changeAirdropAuthorityInstruction(args)
Change the airdrop authority.
const ix = await engine.changeAirdropAuthorityInstruction({
authority: new PublicKey('NEW_AUTHORITY'),
});changePointsProgramExpirationInstruction(args)
Change the points program expiration.
const ix = await engine.changePointsProgramExpirationInstruction({
date: new Date('2025-12-31'),
});changeRefProgramInstruction(args)
Change the referral program parameters.
const ix = await engine.changeRefProgramInstruction({
programDuration: 86400 * 30, // 30 days
linkDuration: 86400 * 7, // 7 days
feesDiscount: 0.1, // 10% discount
feesRatio: 0.5, // 50% ratio
});votingResetInstruction()
Reset voting.
const ix = await engine.votingResetInstruction();Client Operations
depositInstruction(args)
Deposit tokens.
const ix = await engine.depositInstruction({
mint: USDC_MINT,
amount: 100,
});withdrawInstruction(args)
Withdraw tokens.
const ix = await engine.withdrawInstruction({
mint: USDC_MINT,
amount: 50,
});spotLpInstruction(args)
Execute a spot LP operation.
const ix = await engine.spotLpInstruction({
assetTokenId: 1,
crncyTokenId: 0,
side: 0, // 0 = buy, 1 = sell
amount: 10, // percentage
edgePrice: 1.5,
});dividendsClaimInstruction()
Claim dividends.
const ix = await engine.dividendsClaimInstruction();votingInstruction(args)
Submit a vote.
const ix = await engine.votingInstruction({
choice: 1,
votingCounter: 42,
});Direct Instructions (No Multisig Wrapper)
newPrivateClientInstruction(args)
Add a private client (returns raw instruction, not wrapped in multisig).
const ix = engine.newPrivateClientInstruction({
wallet: new PublicKey('CLIENT_WALLET'),
lifeTime: 86400 * 365, // 1 year in seconds
});Utility Methods
findGeneralPda(tag)
Find a general PDA by tag.
findInstrPDA(args)
Find an instrument PDA.
rootAccount()
Get the root account PDA.
communityAccount()
Get the community account PDA.
privateClientsAccount()
Get the private clients account PDA.
tokenAccount(mint)
Get a token account PDA for a given mint.
clientPrimaryAccount()
Get the client primary account PDA.
clientCommunityAccount()
Get the client community account PDA.
checkAccount(account)
Check if an account exists on-chain.
Constants
The package exports the following constants:
import {
VERSION, // Current protocol version
PROGRAM_ID, // Deriverse program ID
DRVS_MINT, // DRVS token mint
USDC_MINT, // USDC token mint
HOLDER_MULTISIG_PDA, // Holder multisig PDA
OPERATOR_MULTISIG_PDA, // Operator multisig PDA
CLIENT_MULTISIG_PDA, // Client multisig PDA
PRIVATE_MODE_AUTHORITY, // Private mode authority
HOLDER_ACCOUNT_SEED, // Holder account seed
DRVS_AUTHORITY_SEED, // DRVS authority seed
} from '@deriverse/sqds-admin-kit';TypeScript Support
This package includes TypeScript definitions. All interfaces are exported:
import type {
AdminEngineArgs,
GetInstrPdaArgs,
NewRootAccountArgs,
NewBaseCurrencyArgs,
NewPrivateClientArgs,
DepositArgs,
WithdrawArgs,
SetVarianceArgs,
SetInstrReadyForPerpUpgradeArgs,
SpotLpArgs,
VotingArgs,
ChangePrivateModeAuthorityArgs,
ChangeAirdropAuthorityArgs,
ChangePointsProgramExpirationArgs,
ChangeRefProgramArgs,
} from '@deriverse/sqds-admin-kit';License
Apache-2.0
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
