SMART SQUARE: Smart Bi-directional Interface for EVs with Market-based Energy Flow Management and Smart Grid Stabilization Capabilities