Optimal compensation with adverse selection and dynamic actions