import { Connection, PublicKey, Keypair, TransactionInstruction, Commitment, AccountInfo, Transaction } from '@solana/web3.js'; import { Program, AnchorProvider } from '@project-serum/anchor'; import Decimal from 'decimal.js'; declare type LifinityAmmV2 = { "version": "0.1.1"; "name": "lifinity_amm_v2"; "instructions": [ { "name": "initialize"; "accounts": [ { "name": "authority"; "isMut": false; "isSigner": false; }, { "name": "amm"; "isMut": true; "isSigner": true; }, { "name": "poolMint"; "isMut": true; "isSigner": false; }, { "name": "tokenA"; "isMut": true; "isSigner": false; }, { "name": "tokenB"; "isMut": true; "isSigner": false; }, { "name": "feeAccount"; "isMut": true; "isSigner": false; }, { "name": "destination"; "isMut": true; "isSigner": false; }, { "name": "oracleMainAccount"; "isMut": false; "isSigner": false; }, { "name": "oracleSubAccount"; "isMut": false; "isSigner": false; }, { "name": "oraclePcAccount"; "isMut": false; "isSigner": false; }, { "name": "tokenProgram"; "isMut": false; "isSigner": false; } ]; "args": [ { "name": "baseDecimals"; "type": "u8"; }, { "name": "ammFees"; "type": { "defined": "AmmFees"; }; }, { "name": "ammCurve"; "type": { "defined": "AmmCurve"; }; }, { "name": "ammConfig"; "type": { "defined": "AmmConfig"; }; } ]; }, { "name": "swap"; "accounts": [ { "name": "authority"; "isMut": false; "isSigner": false; }, { "name": "amm"; "isMut": true; "isSigner": false; }, { "name": "userTransferAuthority"; "isMut": false; "isSigner": true; }, { "name": "sourceInfo"; "isMut": true; "isSigner": false; }, { "name": "destinationInfo"; "isMut": true; "isSigner": false; }, { "name": "swapSource"; "isMut": true; "isSigner": false; }, { "name": "swapDestination"; "isMut": true; "isSigner": false; }, { "name": "poolMint"; "isMut": true; "isSigner": false; }, { "name": "feeAccount"; "isMut": true; "isSigner": false; }, { "name": "tokenProgram"; "isMut": false; "isSigner": false; }, { "name": "oracleMainAccount"; "isMut": false; "isSigner": false; }, { "name": "oracleSubAccount"; "isMut": false; "isSigner": false; }, { "name": "oraclePcAccount"; "isMut": false; "isSigner": false; } ]; "args": [ { "name": "amountIn"; "type": "u64"; }, { "name": "minimumAmountOut"; "type": "u64"; } ]; }, { "name": "depositAllTokenTypes"; "accounts": [ { "name": "amm"; "isMut": true; "isSigner": false; }, { "name": "authority"; "isMut": false; "isSigner": false; }, { "name": "userTransferAuthorityInfo"; "isMut": false; "isSigner": true; }, { "name": "sourceAInfo"; "isMut": true; "isSigner": false; }, { "name": "sourceBInfo"; "isMut": true; "isSigner": false; }, { "name": "tokenA"; "isMut": true; "isSigner": false; }, { "name": "tokenB"; "isMut": true; "isSigner": false; }, { "name": "poolMint"; "isMut": true; "isSigner": false; }, { "name": "destination"; "isMut": true; "isSigner": false; }, { "name": "tokenProgram"; "isMut": false; "isSigner": false; } ]; "args": [ { "name": "poolTokenAmount"; "type": "u64"; }, { "name": "maximumTokenAAmount"; "type": "u64"; }, { "name": "maximumTokenBAmount"; "type": "u64"; } ]; }, { "name": "withdrawAllTokenTypes"; "accounts": [ { "name": "amm"; "isMut": true; "isSigner": false; }, { "name": "authority"; "isMut": false; "isSigner": false; }, { "name": "userTransferAuthorityInfo"; "isMut": false; "isSigner": true; }, { "name": "sourceInfo"; "isMut": true; "isSigner": false; }, { "name": "tokenA"; "isMut": true; "isSigner": false; }, { "name": "tokenB"; "isMut": true; "isSigner": false; }, { "name": "poolMint"; "isMut": true; "isSigner": false; }, { "name": "destTokenAInfo"; "isMut": true; "isSigner": false; }, { "name": "destTokenBInfo"; "isMut": true; "isSigner": false; }, { "name": "tokenProgram"; "isMut": false; "isSigner": false; } ]; "args": [ { "name": "poolTokenAmount"; "type": "u64"; }, { "name": "minimumTokenAAmount"; "type": "u64"; }, { "name": "minimumTokenBAmount"; "type": "u64"; } ]; }, { "name": "ammOracleStatusUpdate"; "accounts": [ { "name": "amm"; "isMut": true; "isSigner": true; } ]; "args": [ { "name": "oracleStatus"; "type": "u64"; } ]; }, { "name": "ammFreezeUpdate"; "accounts": [ { "name": "amm"; "isMut": true; "isSigner": true; } ]; "args": [ { "name": "freezeTrade"; "type": "u8"; }, { "name": "freezeDeposit"; "type": "u8"; }, { "name": "freezeWithdraw"; "type": "u8"; }, { "name": "baseDecimals"; "type": "u8"; } ]; }, { "name": "ammFeeCurveConfigUpdate"; "accounts": [ { "name": "amm"; "isMut": true; "isSigner": true; } ]; "args": [ { "name": "ammFees"; "type": { "defined": "AmmFees"; }; }, { "name": "ammCurve"; "type": { "defined": "AmmCurve"; }; }, { "name": "ammConfig"; "type": { "defined": "AmmConfig"; }; } ]; }, { "name": "ammLastPriceUpdate"; "accounts": [ { "name": "amm"; "isMut": true; "isSigner": true; } ]; "args": [ { "name": "lastPrice"; "type": "u64"; } ]; }, { "name": "ammRegressionTargetUpdate"; "accounts": [ { "name": "amm"; "isMut": false; "isSigner": false; }, { "name": "ammOwner"; "isMut": false; "isSigner": true; } ]; "args": [ { "name": "targetAmount"; "type": "u64"; } ]; } ]; "accounts": [ { "name": "amm"; "type": { "kind": "struct"; "fields": [ { "name": "initializerKey"; "type": "publicKey"; }, { "name": "initializerDepositTokenAccount"; "type": "publicKey"; }, { "name": "initializerReceiveTokenAccount"; "type": "publicKey"; }, { "name": "initializerAmount"; "type": "u64"; }, { "name": "takerAmount"; "type": "u64"; }, { "name": "isInitialized"; "type": "bool"; }, { "name": "bumpSeed"; "type": "u8"; }, { "name": "freezeTrade"; "type": "u8"; }, { "name": "freezeDeposit"; "type": "u8"; }, { "name": "freezeWithdraw"; "type": "u8"; }, { "name": "baseDecimals"; "type": "u8"; }, { "name": "tokenProgramId"; "type": "publicKey"; }, { "name": "tokenAAccount"; "type": "publicKey"; }, { "name": "tokenBAccount"; "type": "publicKey"; }, { "name": "poolMint"; "type": "publicKey"; }, { "name": "tokenAMint"; "type": "publicKey"; }, { "name": "tokenBMint"; "type": "publicKey"; }, { "name": "feeAccount"; "type": "publicKey"; }, { "name": "oracleMainAccount"; "type": "publicKey"; }, { "name": "oracleSubAccount"; "type": "publicKey"; }, { "name": "oraclePcAccount"; "type": "publicKey"; }, { "name": "fees"; "type": { "defined": "AmmFees"; }; }, { "name": "curve"; "type": { "defined": "AmmCurve"; }; }, { "name": "config"; "type": { "defined": "AmmConfig"; }; }, { "name": "ammPTemp1"; "type": "publicKey"; }, { "name": "ammPTemp2"; "type": "publicKey"; }, { "name": "ammPTemp3"; "type": "publicKey"; }, { "name": "ammPTemp4"; "type": "publicKey"; }, { "name": "ammPTemp5"; "type": "publicKey"; } ]; }; } ]; "types": [ { "name": "AmmFees"; "type": { "kind": "struct"; "fields": [ { "name": "tradeFeeNumerator"; "type": "u64"; }, { "name": "tradeFeeDenominator"; "type": "u64"; }, { "name": "ownerTradeFeeNumerator"; "type": "u64"; }, { "name": "ownerTradeFeeDenominator"; "type": "u64"; }, { "name": "ownerWithdrawFeeNumerator"; "type": "u64"; }, { "name": "ownerWithdrawFeeDenominator"; "type": "u64"; }, { "name": "hostFeeNumerator"; "type": "u64"; }, { "name": "hostFeeDenominator"; "type": "u64"; } ]; }; }, { "name": "AmmCurve"; "type": { "kind": "struct"; "fields": [ { "name": "curveType"; "type": "u8"; }, { "name": "curveParameters"; "type": "u64"; } ]; }; }, { "name": "AmmConfig"; "type": { "kind": "struct"; "fields": [ { "name": "lastPrice"; "type": "u64"; }, { "name": "lastBalancedPrice"; "type": "u64"; }, { "name": "configDenominator"; "type": "u64"; }, { "name": "volumeX"; "type": "u64"; }, { "name": "volumeY"; "type": "u64"; }, { "name": "volumeXInY"; "type": "u64"; }, { "name": "depositCap"; "type": "u64"; }, { "name": "regressionTarget"; "type": "u64"; }, { "name": "oracleType"; "type": "u64"; }, { "name": "oracleStatus"; "type": "u64"; }, { "name": "oracleMainSlotLimit"; "type": "u64"; }, { "name": "oracleSubConfidenceLimit"; "type": "u64"; }, { "name": "oracleSubSlotLimit"; "type": "u64"; }, { "name": "oraclePcConfidenceLimit"; "type": "u64"; }, { "name": "oraclePcSlotLimit"; "type": "u64"; }, { "name": "stdSpread"; "type": "u64"; }, { "name": "stdSpreadBuffer"; "type": "u64"; }, { "name": "spreadCoefficient"; "type": "u64"; }, { "name": "priceBufferCoin"; "type": "i64"; }, { "name": "priceBufferPc"; "type": "i64"; }, { "name": "rebalanceRatio"; "type": "u64"; }, { "name": "feeTrade"; "type": "u64"; }, { "name": "feePlatform"; "type": "u64"; }, { "name": "configTemp3"; "type": "u64"; }, { "name": "configTemp4"; "type": "u64"; }, { "name": "configTemp5"; "type": "u64"; }, { "name": "configTemp6"; "type": "u64"; }, { "name": "configTemp7"; "type": "u64"; }, { "name": "configTemp8"; "type": "u64"; } ]; }; }, { "name": "CurveType"; "type": { "kind": "enum"; "variants": [ { "name": "Standard"; }, { "name": "ConstantProduct"; } ]; }; }, { "name": "TradeDirection"; "type": { "kind": "enum"; "variants": [ { "name": "AtoB"; }, { "name": "BtoA"; } ]; }; }, { "name": "RoundDirection"; "type": { "kind": "enum"; "variants": [ { "name": "Floor"; }, { "name": "Ceiling"; } ]; }; } ]; "errors": [ { "code": 6000; "name": "AlreadyInUse"; "msg": "Swap account already in use"; }, { "code": 6001; "name": "InvalidProgramAddress"; "msg": "Invalid program address generated from bump seed and key"; }, { "code": 6002; "name": "InvalidOwner"; "msg": "Input account owner is not the program address"; }, { "code": 6003; "name": "InvalidOutputOwner"; "msg": "Output pool account owner cannot be the program address"; }, { "code": 6004; "name": "ExpectedMint"; "msg": "Deserialized account is not an SPL Token mint"; }, { "code": 6005; "name": "ExpectedAccount"; "msg": "Deserialized account is not an SPL Token account"; }, { "code": 6006; "name": "EmptySupply"; "msg": "Input token account empty"; }, { "code": 6007; "name": "InvalidSupply"; "msg": "Pool token mint has a non-zero supply"; }, { "code": 6008; "name": "InvalidDelegate"; "msg": "Token account has a delegate"; }, { "code": 6009; "name": "InvalidInput"; "msg": "InvalidInput"; }, { "code": 6010; "name": "IncorrectSwapAccount"; "msg": "Address of the provided swap token account is incorrect"; }, { "code": 6011; "name": "IncorrectPoolMint"; "msg": "Address of the provided pool token mint is incorrect"; }, { "code": 6012; "name": "InvalidOutput"; "msg": "InvalidOutput"; }, { "code": 6013; "name": "CalculationFailure"; "msg": "General calculation failure due to overflow or underflow"; }, { "code": 6014; "name": "InvalidInstruction"; "msg": "Invalid instruction"; }, { "code": 6015; "name": "RepeatedMint"; "msg": "Swap input token accounts have the same mint"; }, { "code": 6016; "name": "ExceededSlippage"; "msg": "Swap instruction exceeds desired slippage limit"; }, { "code": 6017; "name": "InvalidCloseAuthority"; "msg": "Token account has a close authority"; }, { "code": 6018; "name": "InvalidFreezeAuthority"; "msg": "Pool token mint has a freeze authority"; }, { "code": 6019; "name": "IncorrectFeeAccount"; "msg": "Pool fee token account incorrect"; }, { "code": 6020; "name": "ZeroTradingTokens"; "msg": "Given pool token amount results in zero trading tokens"; }, { "code": 6021; "name": "FeeCalculationFailure"; "msg": "Fee calculation failed due to overflow, underflow, or unexpected 0"; }, { "code": 6022; "name": "ConversionFailure"; "msg": "Conversion to u64 failed with an overflow or underflow"; }, { "code": 6023; "name": "InvalidFee"; "msg": "The provided fee does not match the program owner's constraints"; }, { "code": 6024; "name": "IncorrectTokenProgramId"; "msg": "The provided token program does not match the token program expected by the swap"; }, { "code": 6025; "name": "IncorrectOracleAccount"; "msg": "Address of the provided oracle account is incorrect"; }, { "code": 6026; "name": "IncorrectConfigAccount"; "msg": "Address of the provided config account is incorrect"; }, { "code": 6027; "name": "UnsupportedCurveType"; "msg": "The provided curve type is not supported by the program owner"; }, { "code": 6028; "name": "InvalidCurve"; "msg": "The provided curve parameters are invalid"; }, { "code": 6029; "name": "UnsupportedCurveOperation"; "msg": "The operation cannot be performed on the given curve"; }, { "code": 6030; "name": "InvalidPythStatus"; "msg": "Pyth oracle status is not 'trading'"; }, { "code": 6031; "name": "InvalidPythPrice"; "msg": "Could not retrieve updated price feed from the Pyth oracle"; }, { "code": 6032; "name": "IncorrectSigner"; "msg": "Address of the provided signer account is incorrect"; }, { "code": 6033; "name": "ExceedPoolBalance"; "msg": "Swap amount exceeds pool balance"; }, { "code": 6034; "name": "ProgramIsFrozen"; "msg": "Program is frozen"; }, { "code": 6035; "name": "OracleConfidence"; "msg": "Oracle confidence is too low"; }, { "code": 6036; "name": "OverCapAmount"; "msg": "Over Pool Cap Amount"; }, { "code": 6037; "name": "InvalidUpdateAccount"; "msg": "Invalid update wallet address"; } ]; }; declare const IDL: LifinityAmmV2; declare class Lifinity { connection: Connection; wallet: IWallet; program: Program; provider: AnchorProvider; stateAddress: PublicKey; programAuthority: PublicKey; owner: Keypair; private constructor(); static build(connection: Connection, wallet: any): Promise; swap(amountIn: number, minimumAmountOut: number, fromMint: PublicKey, toMint: PublicKey): Promise; deposit(coinMaximumIn: number, pcMaximumIn: number, lpRecive: number, coinMint: PublicKey, pcMint: PublicKey): Promise; withdraw(lpAmountIn: number, coinMinimumOut: number, pcMinimumOut: number, coinMint: PublicKey, pcMint: PublicKey): Promise; } interface IAmountOut { amountIn: number; amountOut: number; amountOutWithSlippage: number; priceImpact: number; fee: number; feePercent: number; } declare function getAmountOut(connection: Connection, amountIn: number, fromMint: PublicKey, toMint: PublicKey, slippage: number): Promise; interface ISwapInstructions { approveInstruction: TransactionInstruction; swapInstruction: TransactionInstruction; signers: any[]; } declare function getSwapInstruction(connection: Connection, ownerAccount: PublicKey, amountIn: number, minimumOut: number, fromMint: PublicKey, toMint: PublicKey, fromUserAccount: PublicKey, toTokenAccount: PublicKey, approve?: boolean): Promise; declare function getSwapTransactionWithAuthority(connection: Connection, ownerAccount: PublicKey, amountIn: number, minimumAmountOut: number, fromMint: PublicKey, toMint: PublicKey, fromUserAccount: PublicKey, toTokenAccount: PublicKey, authority: PublicKey): Promise; interface IDepositAmountOut { coinMaximumIn: number; pcMaximumIn: number; lpRecive: number; } declare function getDepositAmountOut(connection: Connection, coinAmountIn: number, pcAmountIn: number, coinMint: PublicKey, pcMint: PublicKey, slippage: number): Promise; declare function getDepositInstruction(connection: Connection, ownerAccount: PublicKey, coinAmountIn: number, pcAmountIn: number, lpRecive: number, fromMint: PublicKey, toMint: PublicKey, userCoinTokenAccount: PublicKey, userPcTokenAccount: PublicKey, userLpTokenAccount: PublicKey): Promise; interface IWithdrawAmountOut { lpAmountIn: number; coinMinimumOut: number; pcMinimumOut: number; } declare function getWithdrawAmountOut(connection: Connection, lpAmountIn: number, coinMint: PublicKey, pcMint: PublicKey, slippage: number): Promise; declare function getWithdrawInstruction(connection: Connection, ownerAccount: PublicKey, lpAmountIn: number, coinMinimumOut: number, pcMinimumOut: number, fromMint: PublicKey, toMint: PublicKey, userCoinTokenAccount: PublicKey, userPcTokenAccount: PublicKey, userLpTokenAccount: PublicKey): Promise; declare const getProgramAddress: () => string; declare function getPoolList(): { "SOL-USDC": { amm: string; poolMint: string; feeAccount: string; oracleMainAccount: string; oracleSubAccount: string; oraclePcAccount: string; poolCoinTokenAccount: string; poolCoinMint: string; poolPcTokenAccount: string; poolPcMint: string; poolCoinDecimal: number; poolPcDecimal: number; poolMintDecimal: number; pythBaseDecimal: number; }; "SOL-USDT": { amm: string; poolMint: string; feeAccount: string; oracleMainAccount: string; oracleSubAccount: string; oraclePcAccount: string; poolCoinTokenAccount: string; poolCoinMint: string; poolPcTokenAccount: string; poolPcMint: string; poolCoinDecimal: number; poolPcDecimal: number; poolMintDecimal: number; pythBaseDecimal: number; }; }; interface IPoolInfo { amm: string; poolMint: string; feeAccount: string; oracleMainAccount: string; oracleSubAccount: string; oraclePcAccount: string; poolCoinTokenAccount: string; poolCoinMint: string; poolCoinDecimal: number; poolPcTokenAccount: string; poolPcMint: string; poolPcDecimal: number; poolMintDecimal: number; pythBaseDecimal: number; } declare function getPool(fromMint: string, toMint: string): IPoolInfo; declare type AmmData = { freezeTrade: number; freezeDeposit: number; freezeWithdraw: number; baseDecimals: number; curveType: number; }; declare type FeesData = { tradeFeeNumerator: Decimal; tradeFeeDenominator: Decimal; ownerTradeFeeNumerator: Decimal; ownerTradeFeeDenominator: Decimal; }; declare type ConfigData = { lastPrice: Decimal; lastBalancedPrice: Decimal; configDenominator: Decimal; volumeX: Decimal; volumeY: Decimal; volumeXinY: Decimal; depositCap: Decimal; regressionTarget: Decimal; oracleType: Decimal; oracleStatus: Decimal; oracleMainSlotLimit: Decimal; oracleSubConfidenceLimit: Decimal; oracleSubSlotLimit: Decimal; oraclePcConfidenceLimit: Decimal; oraclePcSlotLimit: Decimal; stdSpread: Decimal; stdSpreadBuffer: Decimal; spreadCoefficient: Decimal; priceBufferCoin: Decimal; priceBufferPc: Decimal; rebalanceRatio: Decimal; }; declare type PythData = { address: string; price: Decimal; confidence: Decimal; status: Decimal; publishSlot: Decimal; exponent: number; }; declare function getMultipleAccounts(connection: Connection, publicKeys: PublicKey[], commitment?: Commitment): Promise; }>>; interface IAmmData { amm: AmmData; fees: FeesData; coinBalance: Decimal; pcBalance: Decimal; config: ConfigData; oracleMain: PythData | undefined; oracleSub: PythData | undefined; oraclePc: PythData | undefined; } declare function getParsedData(multipleInfo: Array; }>, poolInfo: IPoolInfo): IAmmData; declare const TradeDirection: { readonly AtoB: "AtoB"; readonly BtoA: "BtoA"; }; interface ICurveAmount { amountSwapped: Decimal; priceImpact: Decimal; fee: Decimal; feePercent: Decimal; } declare function getCurveAmount(amount: Decimal, slot: number, amm: AmmData, fees: FeesData, coinBalance: Decimal, pcBalance: Decimal, config: ConfigData, oracleMain: PythData | undefined, oracleSub: PythData | undefined, oraclePc: PythData | undefined, tradeDirection: any): ICurveAmount; interface IWallet { signTransaction: (tx: Transaction) => Promise; signAllTransactions: (txs: Transaction[]) => Promise; publicKey: PublicKey; payer: Keypair; } export { IAmmData, IAmountOut, ICurveAmount, IDL, IDepositAmountOut, IPoolInfo, ISwapInstructions, IWallet, IWithdrawAmountOut, Lifinity, LifinityAmmV2, TradeDirection, getAmountOut, getCurveAmount, getDepositAmountOut, getDepositInstruction, getMultipleAccounts, getParsedData, getPool, getPoolList, getProgramAddress, getSwapInstruction, getSwapTransactionWithAuthority, getWithdrawAmountOut, getWithdrawInstruction };