meme-police-sdk v0.1.63
Mastermind SDK
A TypeScript SDK for interacting with the Mastermind Solana program. This SDK provides a comprehensive interface for trading and managing bonding curves on Solana.
Installation
npm install meme-police-sdk
Usage
Initializing the Client
import { MastermindClient, Config } from 'meme-police-sdk/dist/index';
import { AnchorProvider } from '@coral-xyz/anchor';
// Initialize with default config (devnet)
const client = new MastermindClient(provider);
// Or specify a cluster
const config = new Config('mainnet');
const client = new MastermindClient(provider, 'mainnet', config);
Configuration
The SDK supports the following networks:
mainnet
devnet
localnet
Key Features
Trading Operations
- Execute buy/sell trades with exact input or output amounts
- Support for slippage protection
- Automatic fee calculation
Bonding Curve Management
- Create and manage bonding curves
- Query curve states and reserves
- Track virtual and real token/SOL reserves
Account Management
- Query global state
- Manage authority and permissions
- Handle token vaults and associated accounts
Examples
Execute a Trade
const tradeParams = {
tradeType: TradeType.EXACT_IN,
tradeDirection: TradeDirection.BUY,
amountToTrade: new BN(1000000000), // 1 SOL
slippage: 0.01, // 1%
mint: tokenMintPublicKey,
};
const [tradeInfo, error] = await client.getTrade(tradeParams);
if (error) {
console.error('Trade error:', error);
return;
}
console.log('Trade details:', {
inputAmount: tradeInfo.inputAmount.toString(),
outputAmount: tradeInfo.minmaxOutputAmount.toString(),
price: tradeInfo.price.toString(),
fee: tradeInfo.fee.toString(),
});
Query Bonding Curve State
const [bondingCurvePda] = client.getBondingCurveAccounts(mintPublicKey);
const curveState = await client.deserializeCurve(bondingCurvePda.publicKey);
console.log('Curve state:', {
realTokenReserve: curveState.realTokenReserve.toString(),
realSolReserve: curveState.realSolReserve.toString(),
virtualTokenReserve: curveState.virtualTokenReserve.toString(),
virtualSolReserve: curveState.virtualSolReserve.toString(),
});
Error Handling
The SDK provides custom error types for common scenarios:
MastermindRpcError
: RPC-related errors with transaction IDsPermissionError
: Authorization-related errorsSlippageError
: Trade slippage validation errorsTradeError
: General trading-related errors
License
MIT License
Copyright (c) 2024 Meme Police
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago