import { AccountInfo, PublicKey, Transaction } from '@solana/web3.js'; import { IdlAccounts, IdlTypes, Program } from '@coral-xyz/anchor'; import BN from 'bn.js'; import { Amm as AmmIdl } from '../idl'; import { VaultState, VaultIdl } from '@mercurial-finance/vault-sdk'; import Decimal from 'decimal.js'; export type AmmProgram = Program; export type VaultProgram = Program; export interface AmmImplementation { decimals: number; isStablePool: boolean; updateState: () => Promise; getPoolTokenMint: () => PublicKey; getUserBalance: (owner: PublicKey) => Promise; getLpSupply: () => Promise; getSwapQuote: (inTokenMint: PublicKey, inAmountLamport: BN, slippage: number) => SwapQuote; swap: (owner: PublicKey, inTokenMint: PublicKey, inAmountLamport: BN, outAmountLamport: BN) => Promise; getDepositQuote: (tokenAInAmount: BN, tokenBInAmount: BN, isImbalance: boolean, slippage: number) => DepositQuote; deposit: (owner: PublicKey, tokenAInAmount: BN, tokenBInAmount: BN, poolTokenAmount: BN) => Promise; getWithdrawQuote: (lpTokenAmount: BN, slippage: number, tokenMint?: PublicKey) => WithdrawQuote; withdraw: (owner: PublicKey, withdrawTokenAmount: BN, tokenAOutAmount: BN, tokenBOutAmount: BN) => Promise; getUserLockEscrow: (owner: PublicKey) => Promise; } type Fees = { lp?: BN; tokenA: BN; tokenB: BN; }; export type tokenAddressAndDecimals = { address: string; decimals: number; }; export interface LockEscrow { address: PublicKey; amount: BN; fee: { claimed: Fees; unClaimed: Fees; }; } export type SwapQuote = { swapInAmount: BN; swapOutAmount: BN; minSwapOutAmount: BN; fee: BN; priceImpact: Decimal; }; export type DepositQuote = { poolTokenAmountOut: BN; minPoolTokenAmountOut: BN; tokenAInAmount: BN; tokenBInAmount: BN; }; export type WithdrawQuote = { poolTokenAmountIn: BN; minTokenAOutAmount: BN; minTokenBOutAmount: BN; tokenAOutAmount: BN; tokenBOutAmount: BN; }; export interface SwapResult { amountOut: BN; priceImpact: Decimal; fee: BN; } export type AccountsToCache = { apyPdaBuffer: AccountInfo | null; poolBuffer: AccountInfo | null; vaultAPdaBuffer: AccountInfo | null; vaultBPdaBuffer: AccountInfo | null; vaultAReserveBuffer: AccountInfo | null; vaultBReserveBuffer: AccountInfo | null; vaultALpMintBuffer: AccountInfo | null; vaultBLpMintBuffer: AccountInfo | null; poolVaultALpBuffer: AccountInfo | null; poolVaultBLpBuffer: AccountInfo | null; poolLpMintBuffer: AccountInfo | null; marinadeBuffer: AccountInfo | null; solidoBuffer: AccountInfo | null; clockAccountBuffer: AccountInfo | null; }; export declare enum AccountType { APY = "apy", VAULT_A_RESERVE = "vaultAReserve", VAULT_B_RESERVE = "vaultBReserve", VAULT_A_LP = "vaultALp", VAULT_B_LP = "vaultBLp", POOL_VAULT_A_LP = "poolVaultALp", POOL_VAULT_B_LP = "poolVaultBLp", POOL_LP_MINT = "poolLpMint", SYSVAR_CLOCK = "sysClockVar" } export type CurveType = ConstantProductCurve | StableSwapCurve; export type StableSwapCurve = { stable: { amp: BN; tokenMultiplier: TokenMultiplier; depeg: Depeg; lastAmpUpdatedTimestamp: BN; }; }; export type ConstantProductCurve = { constantProduct: {}; }; export type DepegNone = { none: {}; }; export type DepegMarinade = { marinade: {}; }; export type DepegSplStake = { splStake: {}; }; export type DepegLido = { lido: {}; }; export type DepegType = DepegNone | DepegMarinade | DepegLido | DepegSplStake; export interface TokenMultiplier { tokenAMultiplier: BN; tokenBMultiplier: BN; precisionFactor: number; } export type PoolType = PermissionedType | PermissionedlessType; export type PermissionedType = { permissioned: {}; }; export type PermissionedlessType = { permissionless: {}; }; export type PoolState = Omit['pool'], 'curveType' | 'fees' | 'poolType'> & { curveType: CurveType; fees: PoolFees; poolType: PoolType; }; export type Depeg = Omit['Depeg'], 'depegType'> & { depegType: DepegType; }; export type PoolFees = IdlTypes['PoolFees']; export type Bootstrapping = IdlTypes['Bootstrapping']; export type LockEscrowAccount = IdlAccounts['lockEscrow']; export type PoolInformation = { tokenAAmount: BN; tokenBAmount: BN; virtualPrice: number; virtualPriceRaw: BN; }; export type AccountsInfo = { vaultAReserve: BN; vaultBReserve: BN; vaultALpSupply: BN; vaultBLpSupply: BN; poolVaultALp: BN; poolVaultBLp: BN; poolLpSupply: BN; currentTime: BN; currentSlot: BN; }; export interface StakePool { totalLamports: BN; poolTokenSupply: BN; } export declare const StakePoolLayout: any; export interface Clock { slot: BN; epochStartTimestamp: BN; epoch: BN; leaderScheduleEpoch: BN; unixTimestamp: BN; } export declare const ClockLayout: any; /** Utils */ export interface ParsedClockState { info: { epoch: number; epochStartTimestamp: number; leaderScheduleEpoch: number; slot: number; unixTimestamp: number; }; type: string; program: string; space: number; } export type SwapQuoteParam = { poolState: PoolState; vaultA: VaultState; vaultB: VaultState; poolVaultALp: BN; poolVaultBLp: BN; vaultALpSupply: BN; vaultBLpSupply: BN; vaultAReserve: BN; vaultBReserve: BN; currentTime: number; currentSlot: number; depegAccounts: Map>; }; export declare enum ActivationType { Slot = 0, Timestamp = 1 } export {}; //# sourceMappingURL=index.d.ts.map