export const getLiquidationPrice = ( liquidationRatio , coinsMinted , stxCollateral ) => { return ( liquidationRatio * coinsMinted / ( stxCollateral * 100 ) ) . toFixed ( 2 ) ; } ; export const getCollateralToDebtRatio = ( price , coinsMinted , stxCollateral ) => { return ( stxCollateral * price ) / coinsMinted ; } ; export const availableCollateralToWithdraw = ( price , currentStxCollateral , coinsMinted , collateralToDebt ) => { const minimumStxCollateral = ( collateralToDebt * coinsMinted ) / price ; if ( currentStxCollateral - minimumStxCollateral > 0 ) { return ( currentStxCollateral - minimumStxCollateral ) . toFixed ( 2 ) ; } return 0 ; } ; export const availableCoinsToMint = ( price , stxCollateral , currentCoinsMinted , collateralToDebt ) => { const maximumCoinsToMint = ( stxCollateral * price ) / collateralToDebt ; if ( currentCoinsMinted < maximumCoinsToMint ) { return ( maximumCoinsToMint - currentCoinsMinted ) . toFixed ( 2 ) ; } return 0 ; } ; export const tokenTraits = { 'diko' : { 'name' : 'arkadiko-token' } , 'stx' : { 'name' : 'arkadiko-token' } , 'xstx' : { 'name' : 'xstx-token' } } ; export const resolveReserveName = ( collateralToken ) => { if ( collateralToken . toLowerCase ( ) . startsWith ( 'stx' ) ) { return 'arkadiko-stx-reserve-v1-1' ; } else { return 'arkadiko-sip10-reserve-v1-1' ; } } ; export const contractsMap = { "vault-manager" : "arkadiko-freddie-v1-1" , "auction-engine" : "arkadiko-auction-engine-v1-1" , "oracle" : "arkadiko-oracle-v1-1" , "governance" : "arkadiko-governance-v1-1" } ; export const microToReadable = ( amount , decimals = 2 ) => { return ( parseFloat ( amount ) / 1000000 ) . toFixed ( decimals ) ; } ;