import { bool , publicKey , struct , u128 , u32 , u64 , u8 } from '@project-serum/borsh' ; const bufferLayout = require ( 'buffer-layout' ) ; export const AMM_INFO_LAYOUT_V3 = struct ( [ u64 ( 'status' ) , u64 ( 'nonce' ) , u64 ( 'orderNum' ) , u64 ( 'depth' ) , u64 ( 'coinDecimals' ) , u64 ( 'pcDecimals' ) , u64 ( 'state' ) , u64 ( 'resetFlag' ) , u64 ( 'fee' ) , u64 ( 'min_separate' ) , u64 ( 'minSize' ) , u64 ( 'volMaxCutRatio' ) , u64 ( 'pnlRatio' ) , u64 ( 'amountWaveRatio' ) , u64 ( 'coinLotSize' ) , u64 ( 'pcLotSize' ) , u64 ( 'minPriceMultiplier' ) , u64 ( 'maxPriceMultiplier' ) , u64 ( 'needTakePnlCoin' ) , u64 ( 'needTakePnlPc' ) , u64 ( 'totalPnlX' ) , u64 ( 'totalPnlY' ) , u64 ( 'poolTotalDepositPc' ) , u64 ( 'poolTotalDepositCoin' ) , u64 ( 'systemDecimalsValue' ) , publicKey ( 'poolCoinTokenAccount' ) , publicKey ( 'poolPcTokenAccount' ) , publicKey ( 'coinMintAddress' ) , publicKey ( 'pcMintAddress' ) , publicKey ( 'lpMintAddress' ) , publicKey ( 'ammOpenOrders' ) , publicKey ( 'serumMarket' ) , publicKey ( 'serumProgramId' ) , publicKey ( 'ammTargetOrders' ) , publicKey ( 'ammQuantities' ) , publicKey ( 'poolWithdrawQueue' ) , publicKey ( 'poolTempLpTokenAccount' ) , publicKey ( 'ammOwner' ) , publicKey ( 'pnlOwner' ) , publicKey ( 'srmTokenAccount' ) ] ) ; export const AMM_INFO_LAYOUT = struct ( [ u64 ( 'status' ) , u64 ( 'nonce' ) , u64 ( 'orderNum' ) , u64 ( 'depth' ) , u64 ( 'coinDecimals' ) , u64 ( 'pcDecimals' ) , u64 ( 'state' ) , u64 ( 'resetFlag' ) , u64 ( 'fee' ) , u64 ( 'minSize' ) , u64 ( 'volMaxCutRatio' ) , u64 ( 'pnlRatio' ) , u64 ( 'amountWaveRatio' ) , u64 ( 'coinLotSize' ) , u64 ( 'pcLotSize' ) , u64 ( 'minPriceMultiplier' ) , u64 ( 'maxPriceMultiplier' ) , u64 ( 'needTakePnlCoin' ) , u64 ( 'needTakePnlPc' ) , u64 ( 'totalPnlX' ) , u64 ( 'totalPnlY' ) , u64 ( 'systemDecimalsValue' ) , publicKey ( 'poolCoinTokenAccount' ) , publicKey ( 'poolPcTokenAccount' ) , publicKey ( 'coinMintAddress' ) , publicKey ( 'pcMintAddress' ) , publicKey ( 'lpMintAddress' ) , publicKey ( 'ammOpenOrders' ) , publicKey ( 'serumMarket' ) , publicKey ( 'serumProgramId' ) , publicKey ( 'ammTargetOrders' ) , publicKey ( 'ammQuantities' ) , publicKey ( 'poolWithdrawQueue' ) , publicKey ( 'poolTempLpTokenAccount' ) , publicKey ( 'ammOwner' ) , publicKey ( 'pnlOwner' ) ] ) ; export const ACCOUNT_LAYOUT = struct ( [ publicKey ( 'mint' ) , publicKey ( 'owner' ) , u64 ( 'amount' ) , u32 ( 'delegateOption' ) , publicKey ( 'delegate' ) , u8 ( 'state' ) , u32 ( 'isNativeOption' ) , u64 ( 'isNative' ) , u64 ( 'delegatedAmount' ) , u32 ( 'closeAuthorityOption' ) , publicKey ( 'closeAuthority' ) ] ) ; export const MINT_LAYOUT = struct ( [ u32 ( 'mintAuthorityOption' ) , publicKey ( 'mintAuthority' ) , u64 ( 'supply' ) , u8 ( 'decimals' ) , bool ( 'initialized' ) , u32 ( 'freezeAuthorityOption' ) , publicKey ( 'freezeAuthority' ) ] ) ; export const AMM_INFO_LAYOUT_V4 = struct ( [ u64 ( 'status' ) , u64 ( 'nonce' ) , u64 ( 'orderNum' ) , u64 ( 'depth' ) , u64 ( 'coinDecimals' ) , u64 ( 'pcDecimals' ) , u64 ( 'state' ) , u64 ( 'resetFlag' ) , u64 ( 'minSize' ) , u64 ( 'volMaxCutRatio' ) , u64 ( 'amountWaveRatio' ) , u64 ( 'coinLotSize' ) , u64 ( 'pcLotSize' ) , u64 ( 'minPriceMultiplier' ) , u64 ( 'maxPriceMultiplier' ) , u64 ( 'systemDecimalsValue' ) , u64 ( 'minSeparateNumerator' ) , u64 ( 'minSeparateDenominator' ) , u64 ( 'tradeFeeNumerator' ) , u64 ( 'tradeFeeDenominator' ) , u64 ( 'pnlNumerator' ) , u64 ( 'pnlDenominator' ) , u64 ( 'swapFeeNumerator' ) , u64 ( 'swapFeeDenominator' ) , u64 ( 'needTakePnlCoin' ) , u64 ( 'needTakePnlPc' ) , u64 ( 'totalPnlPc' ) , u64 ( 'totalPnlCoin' ) , u128 ( 'poolTotalDepositPc' ) , u128 ( 'poolTotalDepositCoin' ) , u128 ( 'swapCoinInAmount' ) , u128 ( 'swapPcOutAmount' ) , u64 ( 'swapCoin2PcFee' ) , u128 ( 'swapPcInAmount' ) , u128 ( 'swapCoinOutAmount' ) , u64 ( 'swapPc2CoinFee' ) , publicKey ( 'poolCoinTokenAccount' ) , publicKey ( 'poolPcTokenAccount' ) , publicKey ( 'coinMintAddress' ) , publicKey ( 'pcMintAddress' ) , publicKey ( 'lpMintAddress' ) , publicKey ( 'ammOpenOrders' ) , publicKey ( 'serumMarket' ) , publicKey ( 'serumProgramId' ) , publicKey ( 'ammTargetOrders' ) , publicKey ( 'poolWithdrawQueue' ) , publicKey ( 'poolTempLpTokenAccount' ) , publicKey ( 'ammOwner' ) , publicKey ( 'pnlOwner' ) ] ) ; export const DATA_LAYOUT = struct ( [ u8 ( 'instruction' ) , bufferLayout . nu64 ( 'amountIn' ) , bufferLayout . nu64 ( 'minAmountOut' ) ] ) ; export const AMM_INFO_LAYOUT_STABLE = struct ( [ u64 ( 'status' ) , publicKey ( 'own_address' ) , u64 ( 'nonce' ) , u64 ( 'orderNum' ) , u64 ( 'depth' ) , u64 ( 'coinDecimals' ) , u64 ( 'pcDecimals' ) , u64 ( 'state' ) , u64 ( 'resetFlag' ) , u64 ( 'minSize' ) , u64 ( 'volMaxCutRatio' ) , u64 ( 'amountWaveRatio' ) , u64 ( 'coinLotSize' ) , u64 ( 'pcLotSize' ) , u64 ( 'minPriceMultiplier' ) , u64 ( 'maxPriceMultiplier' ) , u64 ( 'systemDecimalsValue' ) , u64 ( 'ammMaxPrice' ) , u64 ( 'ammMiddlePrice' ) , u64 ( 'ammPriceMultiplier' ) , u64 ( 'minSeparateNumerator' ) , u64 ( 'minSeparateDenominator' ) , u64 ( 'tradeFeeNumerator' ) , u64 ( 'tradeFeeDenominator' ) , u64 ( 'pnlNumerator' ) , u64 ( 'pnlDenominator' ) , u64 ( 'swapFeeNumerator' ) , u64 ( 'swapFeeDenominator' ) , u64 ( 'needTakePnlCoin' ) , u64 ( 'needTakePnlPc' ) , u64 ( 'totalPnlPc' ) , u64 ( 'totalPnlCoin' ) , u128 ( 'poolTotalDepositPc' ) , u128 ( 'poolTotalDepositCoin' ) , u128 ( 'swapCoinInAmount' ) , u128 ( 'swapPcOutAmount' ) , u128 ( 'swapPcInAmount' ) , u128 ( 'swapCoinOutAmount' ) , u64 ( 'swapPcFee' ) , u64 ( 'swapCoinFee' ) , publicKey ( 'poolCoinTokenAccount' ) , publicKey ( 'poolPcTokenAccount' ) , publicKey ( 'coinMintAddress' ) , publicKey ( 'pcMintAddress' ) , publicKey ( 'lpMintAddress' ) , publicKey ( 'ammOpenOrders' ) , publicKey ( 'serumMarket' ) , publicKey ( 'serumProgramId' ) , publicKey ( 'ammTargetOrders' ) , publicKey ( 'poolWithdrawQueue' ) , publicKey ( 'poolTempLpTokenAccount' ) , publicKey ( 'ammOwner' ) , publicKey ( 'pnlOwner' ) , u128 ( 'currentK' ) , u128 ( 'padding1' ) , publicKey ( 'padding2' ) ] ) ;