Optimizing market making algorithms to reduce impermanent loss and gas fees