TypeScript SDK for Deriverse protocol administration via Squads multisig on Solana
npm install @deriverse/sqds-admin-kitTypeScript SDK for Deriverse protocol administration via Squads multisig on Solana.
- 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
``bash`
npm install @deriverse/sqds-admin-kitor
yarn add @deriverse/sqds-admin-kitor
pnpm add @deriverse/sqds-admin-kit
- Node.js >= 18.0.0
- @solana/web3.js >= 1.90.0 (peer dependency)
`typescript
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();
`
The main class for interacting with the Deriverse protocol via Squads multisig.
#### Constructor
`typescript`
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
});
#### newHolderAccountInstruction()
Create a new holder account.
`typescript`
const ix = await engine.newHolderAccountInstruction();
#### newOperatorInstruction()
Add a new operator to the protocol.
`typescript`
const ix = await engine.newOperatorInstruction();
#### newRootAccountInstruction(args?)
Initialize the root account.
`typescript`
const ix = await engine.newRootAccountInstruction({
privateMode: true, // Enable private mode
});
#### newBaseCurrencyInstruction(args?)
Add a new base currency to the protocol.
`typescript
import { USDC_MINT } from '@deriverse/sqds-admin-kit';
const ix = await engine.newBaseCurrencyInstruction({
newBaseCrncyMint: USDC_MINT,
});
`
#### setVarianceInstruction(args)
Set variance for an instrument.
`typescript`
const ix = await engine.setVarianceInstruction({
assetTokenId: 1,
crncyTokenId: 0,
variance: 0.04, // 4%
});
#### setInstrReadyForPerpUpgradeInstruction(args)
Mark an instrument as ready for perpetual upgrade.
`typescript`
const ix = await engine.setInstrReadyForPerpUpgradeInstruction({
assetTokenId: 1,
crncyTokenId: 0,
});
#### terminatePrivateModeInstruction()
Terminate private mode.
`typescript`
const ix = await engine.terminatePrivateModeInstruction();
#### changePrivateModeAuthorityInstruction(args)
Change the private mode authority.
`typescript`
const ix = await engine.changePrivateModeAuthorityInstruction({
authority: new PublicKey('NEW_AUTHORITY'),
});
#### changeAirdropAuthorityInstruction(args)
Change the airdrop authority.
`typescript`
const ix = await engine.changeAirdropAuthorityInstruction({
authority: new PublicKey('NEW_AUTHORITY'),
});
#### changePointsProgramExpirationInstruction(args)
Change the points program expiration.
`typescript`
const ix = await engine.changePointsProgramExpirationInstruction({
date: new Date('2025-12-31'),
});
#### changeRefProgramInstruction(args)
Change the referral program parameters.
`typescript`
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.
`typescript`
const ix = await engine.votingResetInstruction();
#### depositInstruction(args)
Deposit tokens.
`typescript`
const ix = await engine.depositInstruction({
mint: USDC_MINT,
amount: 100,
});
#### withdrawInstruction(args)
Withdraw tokens.
`typescript`
const ix = await engine.withdrawInstruction({
mint: USDC_MINT,
amount: 50,
});
#### spotLpInstruction(args)
Execute a spot LP operation.
`typescript`
const ix = await engine.spotLpInstruction({
assetTokenId: 1,
crncyTokenId: 0,
side: 0, // 0 = buy, 1 = sell
amount: 10, // percentage
edgePrice: 1.5,
});
#### dividendsClaimInstruction()
Claim dividends.
`typescript`
const ix = await engine.dividendsClaimInstruction();
#### votingInstruction(args)
Submit a vote.
`typescript`
const ix = await engine.votingInstruction({
choice: 1,
votingCounter: 42,
});
#### newPrivateClientInstruction(args)
Add a private client (returns raw instruction, not wrapped in multisig).
`typescript`
const ix = engine.newPrivateClientInstruction({
wallet: new PublicKey('CLIENT_WALLET'),
lifeTime: 86400 * 365, // 1 year in seconds
});
#### 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.
The package exports the following constants:
`typescript`
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';
This package includes TypeScript definitions. All interfaces are exported:
`typescript``
import type {
AdminEngineArgs,
GetInstrPdaArgs,
NewRootAccountArgs,
NewBaseCurrencyArgs,
NewPrivateClientArgs,
DepositArgs,
WithdrawArgs,
SetVarianceArgs,
SetInstrReadyForPerpUpgradeArgs,
SpotLpArgs,
VotingArgs,
ChangePrivateModeAuthorityArgs,
ChangeAirdropAuthorityArgs,
ChangePointsProgramExpirationArgs,
ChangeRefProgramArgs,
} from '@deriverse/sqds-admin-kit';
Apache-2.0
Contributions are welcome! Please feel free to submit a Pull Request.
- Deriverse
- Squads Protocol
- GitHub Repository
- npm Package