/// import { web3, Program, BN, Address, AnchorProvider } from '@project-serum/anchor'; import { BalancerAmm } from './../target/types/balancer_amm'; import { BalancerAccountChangeInfo, MintActionState, MintConfigs, PoolData } from './constant'; declare class Balancer { private _provider; readonly program: Program; constructor(provider: AnchorProvider, programId: string); /** * Parse pool buffer data. * @param data Pool buffer data. * @returns Pool readable data. */ parsePoolData: (data: Buffer) => PoolData; /** * Get pool data. * @param poolAddress Pool address. * @returns Pool readable data. */ getPoolData: (poolAddress: Address) => Promise; /** * Get all pool data. * @returns All pool readable data. */ getAllPoolData: () => Promise>>[]>; /** * Derive treasurer address of a pool by pool address. * @param poolAddress Pool address. * @returns Treasurer address that holds the token treasuries of the pool. */ deriveTreasurerAddress: (poolAddress: Address) => Promise; /** * Initialize a Pool. This pool will generate with mintsConfigs. * Maximum token in pool = 8 * After the init, the authority need call initializeJoin to add liquidity and active pool. * @param fee The fee of swap. * @param mintsConfigs List mint config of pool (pk, treasury, weight, action status). * @returns { txId, poolAddress } */ initializePool: ({ fee, taxFee, mintsConfigs, taxMan, sendAndConfirm, pool, mintLpt, }: { fee: BN; taxFee: BN; mintsConfigs: MintConfigs[]; taxMan: Address; sendAndConfirm?: boolean | undefined; pool?: web3.Keypair | undefined; mintLpt?: web3.Keypair | undefined; }) => Promise<{ txId: string; poolAddress: string; tx: web3.Transaction; }>; /** * initializeJoin a Pool. This pool will starting add liquidity. * After the join full token, the mint will change status from 'Uninitialized' to 'Initialized'. * @param poolAddress The pool address will be add liquidity. * @param mint token address will be add liquidity. * @returns { txId } */ initializeJoin: ({ poolAddress, mint, amountIn, sendAndConfirm, addCompute, }: { poolAddress: Address; mint: Address; amountIn: BN; sendAndConfirm?: boolean | undefined; addCompute?: number | undefined; }) => Promise<{ txId: string; transaction: web3.Transaction; }>; /** * * @param poolAddress * @param amounts_in * @returns */ addLiquidity: (poolAddress: Address, amounts_in: BN[], sendAndConfirm?: boolean) => Promise<{ txId: string; tx: web3.Transaction; }>; closePool: (poolAddress: Address) => Promise<{ txId: string; }>; /** * * @param poolAddress * @param mint * @param amount_in * @returns */ addSidedLiquidity: (poolAddress: Address, mint: Address, amount_in: BN) => Promise<{ txId: string; }>; /** * * @param poolAddress * @param mint * @param amount_in * @returns */ removeSidedLiquidity: (poolAddress: Address, mint: Address, lpt_amount: BN, sendAndConfirm?: boolean) => Promise<{ txId: string; tx: web3.Transaction; }>; /** * * @param poolAddress * @param lpt_amount * @returns */ removeLiquidity: (poolAddress: Address, lpt_amount: BN) => Promise<{ txId: string; }>; createRemoveLiquidityTransaction: (poolAddress: Address, lpt_amount: BN) => Promise<{ transaction: web3.Transaction; }>; /** * * @param bidAmount * @param bidMint * @param askMint * @param poolAddress * @returns */ swap: (bidAmount: BN, bidMint: Address, askMint: Address, poolAddress: Address, limit: BN, share_fee?: Address[], sendAndConfirm?: boolean) => Promise<{ txId: string; tx: web3.Transaction; }>; route: (bidAmount: BN, routes: { pool: Address; bidMint: Address; askMint: Address; }[], limit: BN) => Promise<{ txId: string; }>; createRouteTransaction: (bidAmount: BN, routes: { pool: Address; bidMint: Address; askMint: Address; }[], limit: BN) => Promise<{ transaction: web3.Transaction; }>; /** * * @param poolAddress * @param actions * @returns */ updateActions: ({ poolAddress, actions, sendAndConfirm, }: { poolAddress: Address; actions: MintActionState[]; sendAndConfirm?: boolean | undefined; }) => Promise<{ txId: string; tx: web3.Transaction; }>; /** * * @param poolAddress * @param weights * @returns */ updateWeights: ({ poolAddress, weights, sendAndConfirm, }: { poolAddress: Address; weights: BN[]; sendAndConfirm?: boolean | undefined; }) => Promise<{ txId: string; tx: web3.Transaction; }>; /** * * @param poolAddress * @returns */ freezePool: ({ poolAddress, sendAndConfirm, }: { poolAddress: Address; sendAndConfirm?: boolean | undefined; }) => Promise<{ txId: string; tx: web3.Transaction; }>; /** * * @param poolAddress * @returns */ thawPool: ({ poolAddress, sendAndConfirm, }: { poolAddress: Address; sendAndConfirm?: boolean | undefined; }) => Promise<{ txId: string; tx: web3.Transaction; }>; /** * * @param poolAddress * @param newOwner * @returns */ transferOwnership: ({ poolAddress, newOwner, sendAndConfirm, }: { poolAddress: Address; newOwner: Address; sendAndConfirm?: boolean | undefined; }) => Promise<{ txId: string; tx: web3.Transaction; }>; /** * Watch account changes * @param callback * @param filters * @returns Watch id */ watch: (callback: (error: string | null, data: (Omit & { data: PoolData; }) | null) => void, filters?: web3.GetProgramAccountsFilter[]) => number; /** * Unwatch a watcher by watch id * @param watchId * @returns */ unwatch: (watchId: number) => Promise; /** * * @param fee * @param taxFee * @param poolAddress * @returns */ updateFee: (poolAddress: Address, fee: BN, taxFee: BN) => Promise<{ txId: string; }>; } export * from '../target/types/balancer_amm'; export * from './constant'; export * from './utils'; export default Balancer;