@raccoonsdev/goatswap-sdk
v0.0.1-76b25b3.0
Published
Use `createReadonlyProgram` or `createProgram` to get an anchor `Program<Goatswap>` to interact with the Goatswap program.
Downloads
23
Readme
@raccoonsdev/goatswap-sdk
Use createReadonlyProgram
or createProgram
to get an anchor Program<Goatswap>
to interact with the Goatswap program.
import { createProgram } from '@raccoonsdev/goatswap-sdk';
import { NodeWallet } from '@project-serum/anchor';
// ... Load your @solana/web3.js keypair
const nodeWallet = new NodeWallet(keypair);
const provider = new AnchorProvider(connection, anchorWallet, {});
const program = createProgram(anchorProvider);
Program methods
initializePair
Initialize a pairdeposit
/withdraw
manage the lamports stored in the pair authority of a pair your owndepositNft
/withdrawNft
manage the NFTs in a pair you ownswapNftForToken
Sell a NFT to a pair for SOLswapTokenForNft
Buy a NFT from a pair for SOL
Helpers
getPairMetasForCollection
uses getProgramAccounts to find all the pairs for a given collection and fetches all the associated pair lamports and NFTs
pairMetasIntoOrderBooks
Transform the pairs given their available liquidities into Asks and Bids orders, to allow order book like visualization