@blockchainbros/vidar-amm-sdk
Version:
TypeScript SDK for Vidar AMM on Solana
301 lines • 16.2 kB
TypeScript
import { AnchorProvider, Idl, Program } from "@coral-xyz/anchor";
import { PublicKey } from "@solana/web3.js";
import { AddLiquidityAccounts, AddLiquidityParams, ClaimProtocolFeesAccounts, ClaimRewardsAccounts, ClaimStakingFeesAccounts, EmergencyWithdrawAccounts, CreateLiquidityAccounts, InitializePositionAccounts, InitializePoolAccounts, InitializePoolParams, RefreshOracleAccounts, InitializeRewardScheduleAccounts, RemoveLiquidityAccounts, RemoveLiquidityParams, RevealArgs, RewardScheduleParams, SetOraclePriceArgs, StakeAccounts, StakeParams, SwapAccounts, SwapArgs, UnstakeAccounts, UpdateInternalOracleAccounts, RefreshOracleArgs, ConfigurePoolAccounts } from "./types";
export declare const VidarAmmIDL: Idl & {
address: string;
};
export { AddLiquidityAccounts, AddLiquidityParams, ClaimProtocolFeesAccounts, ClaimRewardsAccounts, ClaimStakingFeesAccounts, EmergencyWithdrawAccounts, CreateLiquidityAccounts, InitializePoolAccounts, InitializePoolParams, InitializePositionAccounts, InitializeRewardScheduleAccounts, ConfigurePoolAccounts, RemoveLiquidityAccounts, RemoveLiquidityParams, RewardScheduleParams, SetOraclePriceArgs, StakeAccounts, StakeParams, SwapAccounts, SwapArgs, UnstakeAccounts, RefreshOracleAccounts, UpdateInternalOracleAccounts, };
export type VidarAmm = Program<Idl>;
/**
* Instantiate the Vidar AMM Program client.
* @param provider AnchorProvider instance
* @param programId Optional program ID, defaults to IDL address
*/
export declare function createProgram(provider: AnchorProvider, programId?: PublicKey): VidarAmm;
/**
* Helper to load provider and program in one go.
* @param endpoint RPC endpoint URL
* @param wallet Wallet implements Anchor Wallet interface
* @param commitment Optional commitment level
* @param programId Optional program ID override
* @returns VidarAmm program instance
*/
export declare function loadVidarAmm(provider: AnchorProvider, programId?: PublicKey): VidarAmm;
/**
* Initialize a new pool with given parameters.
* @param params.feeBasisPoints - The fee basis points.
* @param params.isStable - Whether the pool is stable.
* @param accounts.payer - The payer of the transaction.
* @param accounts.pool - The pool to initialize.
* @param accounts.authority - The authority of the pool.
* @param accounts.tokenA - The token A to initialize the pool with.
* @param accounts.tokenB - The token B to initialize the pool with.
* @param accounts.vaultA - The vault to initialize the pool with.
* @param accounts.vaultB - The vault to initialize the pool with.
* @param accounts.feeVault - The fee vault to initialize the pool with.
* @param accounts.stakingRewardVault - The staking reward vault to initialize the pool with.
* @param accounts.lpStakeVault - The LP stake vault to initialize the pool with.
* @param accounts.lpMint - The LP mint to initialize the pool with.
* @param accounts.systemProgram - The system program.
* @returns Transaction instruction to initialize the pool.
*/
export declare function initializePool(program: Program<typeof VidarAmmIDL>, accounts: {
[K in keyof InitializePoolAccounts]: PublicKey;
}, params: InitializePoolParams): Promise<import("@solana/web3.js").Transaction>;
/**
* Create a new liquidity position.
* @param accounts.user - The user creating the liquidity position.
* @param accounts.pool - The pool to create the liquidity position in.
* @param accounts.position - The position to create.
* @param accounts.systemProgram - The system program.
* @param accounts.rent - The rent program.
* @returns Transaction instruction to create a new liquidity position.
*/
export declare function createLiquidityPosition(program: Program<typeof VidarAmmIDL>, accounts: {
[key: string]: PublicKey;
}): Promise<import("@solana/web3.js").Transaction>;
/**
* Add liquidity to a pool.
* @param params.amountA - The amount of token A to add liquidity.
* @param params.amountB - The amount of token B to add liquidity.
* @param accounts.user - The user adding liquidity.
* @param accounts.pool - The pool to add liquidity to.
* @param accounts.userTokenA - The user's token A to add liquidity to.
* @param accounts.userTokenB - The user's token B to add liquidity to.
* @param accounts.vaultA - The vault to add liquidity to.
* @param accounts.vaultB - The vault to add liquidity to.
* @param accounts.lpMint - The LP mint to add liquidity to.
* @param accounts.userLpToken - The user's LP token to add liquidity to.
* @param accounts.authority - The authority of the pool.
* @param accounts.position - The position to add liquidity to.
* @param accounts.tokenProgram - The token program.
* @param accounts.systemProgram - The system program.
* @param accounts.rent - The rent program.
*/
export declare function addLiquidity(program: Program<typeof VidarAmmIDL>, accounts: {
[key: string]: PublicKey;
}, params: AddLiquidityParams): Promise<import("@solana/web3.js").Transaction>;
/**
* Remove liquidity from a pool.
* @param params.lpAmount - The amount of LP tokens to remove.
* @param accounts.user - The user removing liquidity.
* @param accounts.pool - The pool to remove liquidity from.
* @param accounts.vaultA - The vault to remove liquidity from.
* @param accounts.vaultB - The vault to remove liquidity from.
* @param accounts.userTokenA - The user's token A to remove liquidity from.
* @param accounts.userTokenB - The user's token B to remove liquidity from.
* @param accounts.lpMint - The LP mint to remove liquidity from.
* @param accounts.userLpToken - The user's LP token to remove liquidity from.
* @param accounts.position - The position to remove liquidity from.
* @param accounts.authority - The authority of the pool.
* @param accounts.tokenProgram - The token program.
* @returns Transaction instruction to remove liquidity.
*/
export declare function removeLiquidity(program: Program<typeof VidarAmmIDL>, accounts: {
[key: string]: PublicKey;
}, params: RemoveLiquidityParams): Promise<import("@solana/web3.js").Transaction>;
/**
* Swap tokens in the pool.
* @param args.amountIn - The amount of tokens to swap in.
* @param args.minAmountOut - The minimum amount of tokens to receive.
* @param args.deadline - The deadline for the swap.
* @returns Transaction instruction to swap tokens.
* @param accounts.user - The user swapping.
* @param accounts.pool - The pool to swap in.
* @param accounts.userSource - The user's source token to swap.
* @param accounts.userDestination - The user's destination token to swap.
* @param accounts.vaultSource - The vault to swap from.
* @param accounts.vaultDestination - The vault to swap to.
* @param accounts.feeVault - The fee vault to swap to.
* @param accounts.stakingRewardVault - The staking reward vault to swap to.
* @param accounts.authority - The authority of the pool.
* @param accounts.vaultSourceMint - The source mint to swap from.
* @param accounts.vaultDestinationMint - The destination mint to swap to.
* @param accounts.treasuryVault - The treasury vault to swap to.
* @param accounts.associatedTokenProgram - The associated token program.
* @param accounts.tokenProgram - The token program.
* @param accounts.systemProgram - The system program.
*/
export declare function swap(program: Program<typeof VidarAmmIDL>, accounts: {
[key: string]: PublicKey;
}, args: SwapArgs): Promise<import("@solana/web3.js").Transaction>;
/**
* Reveal a swap commitment.
* @param args.nonce - The nonce of the swap.
* @param args.commitSlot - The commit slot of the swap.
* @param args.amountIn - The amount of tokens to swap in.
* @param args.minAmountOut - The minimum amount of tokens to receive.
* @param args.deadline - The deadline for the swap.
* @param accounts.user - The user revealing.
* @param accounts.pool - The pool to reveal to.
* @param accounts.userSource - The user's source token to reveal.
* @param accounts.userDest - The user's destination token to reveal.
* @param accounts.vaultSource - The vault to reveal from.
* @param accounts.vaultDest - The vault to reveal to.
* @param accounts.feeVault - The fee vault to reveal to.
* @param accounts.stakingRewardVault - The staking reward vault to reveal to.
* @param accounts.authority - The authority of the pool.
* @param accounts.tokenProgram - The token program.
* @param accounts.commitIndex - The commit index to reveal to.
* @param accounts.commit - The commit to reveal to.
* @param accounts.vaultSourceMint - The source mint to reveal to.
* @param accounts.vaultDestinationMint - The destination mint to reveal to.
* @param accounts.treasuryVault - The treasury vault to reveal to.
* @param accounts.associatedTokenProgram - The associated token program.
*/
export declare function swapReveal(program: Program<typeof VidarAmmIDL>, accounts: {
[key: string]: PublicKey;
}, args: RevealArgs): Promise<import("@solana/web3.js").Transaction>;
/**
* Initialize a new stake account.
* @param accounts.user - The user initializing the stake account.
* @param accounts.pool - The pool to initialize the stake account in.
* @param accounts.userLpToken - The user's LP token to initialize the stake account with.
* @param accounts.stakeVault - The stake vault to initialize the stake account with.
* @param accounts.authority - The authority of the pool.
* @param accounts.stakeAccount - The stake account to initialize.
* @param accounts.tokenProgram - The token program.
* @param accounts.systemProgram - The system program.
* @param accounts.rent - The rent program.
* @returns Transaction instruction to initialize a new stake account.
*/
export declare function initializeStake(program: Program<typeof VidarAmmIDL>, accounts: {
[key: string]: PublicKey;
}, params: StakeParams): Promise<import("@solana/web3.js").Transaction>;
/**
* Stake LP tokens into the staking vault.
* @param params.amount - The amount of LP tokens to stake.
* @param accounts.user - The user staking.
* @param accounts.pool - The pool to stake to.
* @param accounts.userLpToken - The user's LP token to stake.
* @param accounts.stakeVault - The stake vault to stake to.
* @param accounts.authority - The authority of the pool.
* @param accounts.stakeAccount - The stake account to stake to.
* @param accounts.tokenProgram - The token program.
* @returns Transaction instruction to stake LP tokens.
*/
export declare function stake(program: Program<typeof VidarAmmIDL>, accounts: {
[key: string]: PublicKey;
}, params: StakeParams): Promise<import("@solana/web3.js").Transaction>;
/**
* Unstake LP tokens from the staking vault.
* @param params.amount - The amount of LP tokens to unstake.
* @param accounts.user - The user unstaking.
* @param accounts.pool - The pool to unstake from.
* @param accounts.userLpToken - The user's LP token to unstake.
* @param accounts.stakeVault - The stake vault to unstake from.
* @param accounts.stakeAccount - The stake account to unstake from.
* @param accounts.authority - The authority of the pool.
* @param accounts.tokenProgram - The token program.
*/
export declare function unstake(program: Program<typeof VidarAmmIDL>, accounts: {
[key: string]: PublicKey;
}, params: StakeParams): Promise<import("@solana/web3.js").Transaction>;
/**
* Claim protocol fees from the pool.
* @returns Transaction instruction to claim protocol fees.
* @param accounts.pool - The pool to claim from.
* @param accounts.feeVault - The fee vault to claim from.
* @param accounts.treasury - The treasury to claim to.
* @param accounts.authority - The authority of the pool.
* @param accounts.tokenProgram - The token program.
*/
export declare function claimProtocolFees(program: Program<typeof VidarAmmIDL>, accounts: {
[key: string]: PublicKey;
}): Promise<import("@solana/web3.js").Transaction>;
/**
* Claim rewards from staking.
* @returns Transaction instruction to claim rewards.
* @param accounts.user - The user claiming.
* @param accounts.pool - The pool to claim from.
* @param accounts.stakeAccount - The stake account to claim from.
* @param accounts.stakingRewardVault - The staking reward vault to claim from.
* @param accounts.lpStakeVault - The LP stake vault to claim from.
* @param accounts.userRewardAccount - The user's reward account to claim to.
* @param accounts.authority - The authority of the pool.
* @param accounts.tokenProgram - The token program.
*/
export declare function claimRewards(program: Program<typeof VidarAmmIDL>, accounts: {
[key: string]: PublicKey;
}): Promise<import("@solana/web3.js").Transaction>;
/**
* Claim staking fees from the pool.
* @returns Transaction instruction to claim staking fees.
* @param accounts.user - The user claiming.
* @param accounts.pool - The pool to claim from.
* @param accounts.stakeAccount - The stake account to claim from.
* @param accounts.stakingRewardVault - The staking reward vault to claim from.
* @param accounts.userRewardAccount - The user's reward account to claim to.
* @param accounts.authority - The authority of the pool.
* @param accounts.tokenProgram - The token program.
*/
export declare function claimStakingFees(program: Program<typeof VidarAmmIDL>, accounts: {
[key: string]: PublicKey;
}): Promise<import("@solana/web3.js").Transaction>;
/**
* Emergency withdraw from staking.
* @returns Transaction instruction to emergency withdraw from staking.
* @param accounts.user - The user withdrawing.
* @param accounts.stakeAccount - The stake account to withdraw from.
* @param accounts.pool - The pool to withdraw from.
* @param accounts.stakeVault - The stake vault to withdraw from.
* @param accounts.userLpToken - The user's LP token to withdraw.
* @param accounts.authority - The authority of the pool.
* @param accounts.tokenProgram - The token program.
*/
export declare function emergencyWithdraw(program: Program<typeof VidarAmmIDL>, accounts: {
[key: string]: PublicKey;
}): Promise<import("@solana/web3.js").Transaction>;
/**
* Update the internal oracle price.
* @param args.source.Manual - The manual price to use.
* @param args.source.Twap - The twap price to use.
* @returns Transaction instruction to update the internal oracle price.
*/
export declare function updateInternalOracle(program: Program<typeof VidarAmmIDL>, accounts: {
[key: string]: PublicKey;
}, args: SetOraclePriceArgs): Promise<import("@solana/web3.js").Transaction>;
/**
* Refresh the oracle price.
* @param args.poolKey - The pool to refresh the oracle price for.
* @param accounts.pool - The pool to refresh the oracle price for.
* @param accounts.vaultA - The vault A to refresh the oracle price for.
* @param accounts.vaultB - The vault B to refresh the oracle price for.
* @returns Transaction instruction to refresh the oracle price.
*/
export declare function refreshOracle(program: Program<typeof VidarAmmIDL>, accounts: {
[key: string]: PublicKey;
} & RefreshOracleAccounts, args: RefreshOracleArgs): Promise<import("@solana/web3.js").Transaction>;
/**
* Configure the pool.
* @param pause 0 = unpaused, 1 = paused.
* @param feeBasisPoints - The fee basis points.
* @param isStable - Whether the pool is stable.
* @param accounts.pool - The pool to configure.
* @param accounts.admin - The admin of the pool.
* @returns Transaction instruction to configure the pool.
*/
export declare function configurePool(program: Program<typeof VidarAmmIDL>, accounts: {
pool: PublicKey;
admin: PublicKey;
}, feeBasisPoints: number, isStable: number, pause: number): Promise<import("@solana/web3.js").Transaction>;
declare const _default: {
VidarAmmIDL: Idl & {
address: string;
};
createProgram: typeof createProgram;
loadVidarAmm: typeof loadVidarAmm;
initializePool: typeof initializePool;
addLiquidity: typeof addLiquidity;
removeLiquidity: typeof removeLiquidity;
swap: typeof swap;
swapReveal: typeof swapReveal;
initializeStake: typeof initializeStake;
stake: typeof stake;
unstake: typeof unstake;
claimProtocolFees: typeof claimProtocolFees;
claimRewards: typeof claimRewards;
claimStakingFees: typeof claimStakingFees;
};
export default _default;
//# sourceMappingURL=index.d.ts.map