Package Exports
- @prism-hq/prism-ag
- @prism-hq/prism-ag/dist/prism-ag.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@prism-hq/prism-ag) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
prism-sdk
Initialization
import { Prism } from "@prism-hq/prism-ag";
let prism = await Prism.init({
// user executing swap
user: PublicKey | Keypair | Wallet, // optional (if you don't provide upon init, then you'll need to call prism.setSigner() after user connects the wallet)
host: { // optional
// host platform fee account publickey base58
publicKey: string,
// fee bps e.g 5 ~= 0.05%
fee: number,
},
// rpc connection
connection: Connection, // optional
// slippage
slippage: number, // optional
// same format as solanaTokenList.json
tokenList: {tokens:Array<any>} // optional
});Executing swap
await prism.loadRoutes("USDC", "PRISM"); // load routes for tokens, tokenSymbol | tokenMint (base58 string)
let routes = prism.getRoutes(10); // get routes based on from Token amount 10 USDC -> ? PRISM
let result = await prism.swap(routes[0]); // execute swap (transaction sent, waiting for confirmations)
let finalized = await prism.confirmSwap(result); // get execution details from the blockchainMore functions
// setSigner KeyPair | Wallet before executing swap if not provided upon initialization
await prism.setSigner(KeyPair|Wallet);
// change slippage 1 = 1%
prism.setSlippage(1);
// get user token accounts
prism.getUserAccounts();
// get user OpenOrders accounts
prism.getUserOpenOrders();