@bbachain/spl-token-swap
Version:
JavaScript/TypeScript bindings for the Solana Program Library (SPL) Token Swap program.
119 lines • 4.46 kB
TypeScript
/// <reference types="node" />
/// <reference types="node" />
import * as beet from '@bbachain/beet';
import * as beetBBA from '@bbachain/beet-bbachain';
import * as web3 from '@bbachain/web3.js';
import { Fees, SwapCurve } from '../types';
/**
* Arguments used to create {@link TokenSwap}
* @category Accounts
*/
export type TokenSwapArgs = {
isInitialized: boolean;
bumpSeed: number;
tokenProgramId: web3.PublicKey;
tokenA: web3.PublicKey;
tokenB: web3.PublicKey;
poolMint: web3.PublicKey;
tokenAMint: web3.PublicKey;
tokenBMint: web3.PublicKey;
poolFeeAccount: web3.PublicKey;
fees: Fees;
swapCurve: SwapCurve;
};
/**
* @category userTypes
*/
export declare const tokenSwapBeet: beet.FixableBeetArgsStruct<TokenSwapArgs & {
accountDiscriminator: number;
}>;
/**
* Holds the data for the {@link TokenSwap} Account and provides de/serialization
* functionality for that data
*
* @category Accounts
*/
export declare class TokenSwap implements TokenSwapArgs {
readonly isInitialized: boolean;
readonly bumpSeed: number;
readonly tokenProgramId: web3.PublicKey;
readonly tokenA: web3.PublicKey;
readonly tokenB: web3.PublicKey;
readonly poolMint: web3.PublicKey;
readonly tokenAMint: web3.PublicKey;
readonly tokenBMint: web3.PublicKey;
readonly poolFeeAccount: web3.PublicKey;
readonly fees: Fees;
readonly swapCurve: SwapCurve;
private constructor();
/**
* Creates a {@link TokenSwap} instance from the provided args.
*/
static fromArgs(args: TokenSwapArgs): TokenSwap;
/**
* Deserializes the {@link TokenSwap} from the data of the provided {@link web3.AccountInfo}.
* @returns a tuple of the account data and the offset up to which the buffer was read to obtain it.
*/
static fromAccountInfo(accountInfo: web3.AccountInfo<Buffer>, offset?: number): [TokenSwap, number];
/**
* Retrieves the account info from the provided address and deserializes
* the {@link TokenSwap} from its data.
*
* @throws Error if no account info is found at the address or if deserialization fails
*/
static fromAccountAddress(connection: web3.Connection, address: web3.PublicKey, commitmentOrConfig?: web3.Commitment | web3.GetAccountInfoConfig): Promise<TokenSwap>;
/**
* Provides a {@link web3.Connection.getProgramAccounts} config builder,
* to fetch accounts matching filters that can be specified via that builder.
*
* @param programId - the program that owns the accounts we are filtering
*/
static gpaBuilder(programId?: web3.PublicKey): beetBBA.GpaBuilder<TokenSwapArgs & {
accountDiscriminator: number;
}>;
/**
* Deserializes the {@link TokenSwap} from the provided data Buffer.
* @returns a tuple of the account data and the offset up to which the buffer was read to obtain it.
*/
static deserialize(buf: Buffer, offset?: number): [TokenSwap, number];
/**
* Serializes the {@link TokenSwap} into a Buffer.
* @returns a tuple of the created Buffer and the offset up to which the buffer was written to store it.
*/
serialize(): [Buffer, number];
/**
* Returns the byteSize of a {@link Buffer} holding the serialized data of
* {@link TokenSwap} for the provided args.
*
* @param args need to be provided since the byte size for this account
* depends on them
*/
static byteSize(args: TokenSwapArgs): number;
/**
* Fetches the minimum balance needed to exempt an account holding
* {@link TokenSwap} data from rent
*
* @param args need to be provided since the byte size for this account
* depends on them
* @param connection used to retrieve the rent exemption information
*/
static getMinimumBalanceForRentExemption(args: TokenSwapArgs, connection: web3.Connection, commitment?: web3.Commitment): Promise<number>;
/**
* Returns a readable version of {@link TokenSwap} properties
* and can be used to convert to JSON and/or logging
*/
pretty(): {
isInitialized: boolean;
bumpSeed: number;
tokenProgramId: string;
tokenA: string;
tokenB: string;
poolMint: string;
tokenAMint: string;
tokenBMint: string;
poolFeeAccount: string;
fees: Fees;
swapCurve: SwapCurve;
};
}
//# sourceMappingURL=TokenSwap.d.ts.map