mattdrayer/api: Reworked proforma grade algorithm